[clang-sycl-linker] Forward all --ocloc-options occurrences to ocloc (#211075)

getLastArgValue() only returned the final --ocloc-options= occurrence,
silently dropping earlier ones when the option is passed multiple
times (one token per occurrence). Use getAllArgValues() so every
occurrence is forwarded to ocloc.
This commit is contained in:
Alexey Bader 2026-07-21 15:59:12 -07:00 committed by GitHub
parent 4fff13bfb9
commit 3782c00acd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 2 deletions

View file

@ -118,6 +118,12 @@
; AOT-INTEL-GPU-NEXT: sycl-bundle: image kind: o, triple: spirv64, arch: bmg_g21
; AOT-INTEL-GPU-NOT: {{.+}}
;
; Test that all --ocloc-options are passed to ocloc, even if they contain spaces or quotes.
; RUN: clang-sycl-linker --dry-run -v --module-split-mode=link_unit -arch=bmg_g21 %t/input1.bc -o %t/aot-gpu.out 2>&1 \
; RUN: --ocloc-options="-a -b" --ocloc-options=-c --ocloc-options="d" --ocloc-options='"-e -f"' \
; RUN: | FileCheck %s --check-prefix=AOT-INTEL-OCLOC-OPTIONS
; AOT-INTEL-OCLOC-OPTIONS: "{{.*}}ocloc{{.*}}" {{.*}}-device bmg_g21 -a -b -c d "-e -f"
;
; Test AOT compilation for an Intel CPU.
; Test that IMG_Object image kind is set for AOT compilation (Intel CPU).
; RUN: clang-sycl-linker --dry-run -v --module-split-mode=link_unit -arch=graniterapids %t/input1.bc %t/input2.bc -o %t/aot-cpu.out 2>&1 \

View file

@ -725,8 +725,11 @@ static Error runAOTCompileIntelGPU(StringRef InputFile, StringRef OutputFile,
CmdArgs.push_back("-device");
CmdArgs.push_back(Arch);
StringRef ExtraArgs = Args.getLastArgValue(OPT_ocloc_options_EQ);
ExtraArgs.split(CmdArgs, " ", /*MaxSplit=*/-1, /*KeepEmpty=*/false);
// getAllArgValues returns a temporary vector; retain it so the StringRefs
// remain valid through the executeCommands call below.
std::vector<std::string> ExtraArgsStorage =
Args.getAllArgValues(OPT_ocloc_options_EQ);
llvm::append_range(CmdArgs, ExtraArgsStorage);
CmdArgs.push_back("-output");
CmdArgs.push_back(OutputFile);