diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -2977,7 +2977,7 @@ << "--offload"; } - // Collect all cuda_gpu_arch parameters, removing duplicates. + // Collect all offload arch parameters, removing duplicates. std::set GpuArchs; bool Error = false; for (Arg *A : Args) { @@ -2986,21 +2986,22 @@ continue; A->claim(); - StringRef ArchStr = A->getValue(); - if (A->getOption().matches(options::OPT_no_offload_arch_EQ) && - ArchStr == "all") { - GpuArchs.clear(); - continue; + for (StringRef ArchStr : llvm::split(A->getValue(), ",")) { + if (A->getOption().matches(options::OPT_no_offload_arch_EQ) && + ArchStr == "all") { + GpuArchs.clear(); + } else { + ArchStr = getCanonicalOffloadArch(ArchStr); + if (ArchStr.empty()) { + Error = true; + } else if (A->getOption().matches(options::OPT_offload_arch_EQ)) + GpuArchs.insert(ArchStr); + else if (A->getOption().matches(options::OPT_no_offload_arch_EQ)) + GpuArchs.erase(ArchStr); + else + llvm_unreachable("Unexpected option."); + } } - ArchStr = getCanonicalOffloadArch(ArchStr); - if (ArchStr.empty()) { - Error = true; - } else if (A->getOption().matches(options::OPT_offload_arch_EQ)) - GpuArchs.insert(ArchStr); - else if (A->getOption().matches(options::OPT_no_offload_arch_EQ)) - GpuArchs.erase(ArchStr); - else - llvm_unreachable("Unexpected option."); } auto &&ConflictingArchs = getConflictOffloadArchCombination(GpuArchs); @@ -4356,14 +4357,15 @@ llvm::DenseSet Archs; for (auto &Arg : Args) { if (Arg->getOption().matches(options::OPT_offload_arch_EQ)) { - Archs.insert( - getCanonicalArchString(C, Args, Arg->getValue(), TC->getTriple())); + for (StringRef Arch : llvm::split(Arg->getValue(), ",")) + Archs.insert(getCanonicalArchString(C, Args, Arch, TC->getTriple())); } else if (Arg->getOption().matches(options::OPT_no_offload_arch_EQ)) { - if (Arg->getValue() == StringRef("all")) - Archs.clear(); - else - Archs.erase( - getCanonicalArchString(C, Args, Arg->getValue(), TC->getTriple())); + for (StringRef Arch : llvm::split(Arg->getValue(), ",")) { + if (Arch == StringRef("all")) + Archs.clear(); + else + Archs.erase(getCanonicalArchString(C, Args, Arch, TC->getTriple())); + } } } diff --git a/clang/test/Driver/cuda-bindings.cu b/clang/test/Driver/cuda-bindings.cu --- a/clang/test/Driver/cuda-bindings.cu +++ b/clang/test/Driver/cuda-bindings.cu @@ -40,6 +40,7 @@ // Test two gpu architectures with complete compilation. // // RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings --cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s 2>&1 \ +// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings --offload-arch=sm_30,sm_35 %s 2>&1 \ // RUN: | FileCheck -check-prefix=BIN2 %s // BIN2: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: // BIN2-NOT: cuda-bindings-device-cuda-nvptx64 diff --git a/clang/test/Driver/openmp-offload-gpu-new.c b/clang/test/Driver/openmp-offload-gpu-new.c --- a/clang/test/Driver/openmp-offload-gpu-new.c +++ b/clang/test/Driver/openmp-offload-gpu-new.c @@ -51,6 +51,8 @@ // CHECK-TEMP-BINDINGS: "x86_64-unknown-linux-gnu" - "Offload::Packager", inputs: ["[[DEVICE_OBJ:.+]]"], output: "[[BINARY:.+.out]]" // RUN: %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda --offload-arch=sm_52 --offload-arch=sm_70 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-ARCH-BINDINGS +// RUN: %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda --offload-arch=sm_52,sm_70 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-ARCH-BINDINGS +// RUN: %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda --offload-arch=sm_52,sm_70,sm_35,sm_80 --no-offload-arch=sm_35,sm_80 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-ARCH-BINDINGS // CHECK-ARCH-BINDINGS: "x86_64-unknown-linux-gnu" - "clang", inputs: ["[[INPUT:.*]]"], output: "[[HOST_BC:.*]]" // CHECK-ARCH-BINDINGS: "nvptx64-nvidia-cuda" - "clang", inputs: ["[[INPUT]]", "[[HOST_BC]]"], output: "[[DEVICE_BC_SM_52:.*]]" // CHECK-ARCH-BINDINGS: "nvptx64-nvidia-cuda" - "NVPTX::Assembler", inputs: ["[[DEVICE_BC_SM_52]]"], output: "[[DEVICE_OBJ_SM_52:.*]]"