https://github.com/jhuber6 updated 
https://github.com/llvm/llvm-project/pull/123359

>From 85c697ed272debf032d194ea6ef4b85411350958 Mon Sep 17 00:00:00 2001
From: Joseph Huber <hube...@outlook.com>
Date: Fri, 17 Jan 2025 09:35:34 -0600
Subject: [PATCH] [HIP] Move HIP to the new driver by default

Summary:
This patch matches CUDA, moving the HIP compilation jobs to the new
driver by default. The old behavior will return with
`--no-offload-new-driver`. The main difference is that objects compiled
with the old driver are no longer compatible and will need to be
recompiled or the old driver used.
---
 clang/lib/Driver/Driver.cpp                   | 25 ++++++-------
 clang/lib/Driver/ToolChains/Clang.cpp         |  7 ++--
 clang/lib/Driver/ToolChains/Darwin.cpp        |  4 ++-
 clang/test/Driver/cl-offload.cu               |  5 ++-
 clang/test/Driver/cuda-arch-translation.cu    | 36 +++++++++----------
 ...-file-flag-with-multiple-offload-archs.hip |  5 +--
 clang/test/Driver/hip-code-object-version.hip |  5 +--
 clang/test/Driver/hip-gz-options.hip          |  7 ++--
 clang/test/Driver/hip-macros.hip              |  3 --
 clang/test/Driver/hip-offload-arch.hip        |  4 +--
 clang/test/Driver/hip-options.hip             | 11 ++----
 clang/test/Driver/hip-sanitize-options.hip    |  2 +-
 clang/test/Driver/hip-save-temps.hip          | 12 +++----
 clang/test/Driver/hip-thinlto.hip             |  8 ++---
 .../test/Driver/hip-toolchain-device-only.hip |  4 ---
 clang/test/Driver/hip-toolchain-mllvm.hip     |  2 --
 clang/test/Driver/hip-toolchain-no-rdc.hip    | 12 +++++--
 clang/test/Driver/hip-toolchain-opt.hip       | 35 ++++++------------
 .../Driver/hipspv-link-static-library.hip     |  4 +--
 clang/test/Driver/hipspv-pass-plugin.hip      |  8 ++---
 clang/test/Driver/hipspv-toolchain.hip        |  2 +-
 clang/unittests/Tooling/ToolingTest.cpp       |  6 ++--
 22 files changed, 90 insertions(+), 117 deletions(-)

diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 8c0bba938a09b..58867f518b4cb 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -4325,14 +4325,9 @@ void Driver::BuildActions(Compilation &C, DerivedArgList 
&Args,
 
   handleArguments(C, Args, Inputs, Actions);
 
-  bool UseNewOffloadingDriver =
-      C.isOffloadingHostKind(Action::OFK_OpenMP) ||
-      C.isOffloadingHostKind(Action::OFK_SYCL) ||
-      Args.hasFlag(options::OPT_foffload_via_llvm,
-                   options::OPT_fno_offload_via_llvm, false) ||
-      Args.hasFlag(options::OPT_offload_new_driver,
-                   options::OPT_no_offload_new_driver,
-                   C.isOffloadingHostKind(Action::OFK_Cuda));
+  bool UseNewOffloadingDriver = Args.hasFlag(
+      options::OPT_offload_new_driver, options::OPT_no_offload_new_driver,
+      C.getActiveOffloadKinds() != Action::OFK_None);
 
   bool HIPNoRDC =
       C.isOffloadingHostKind(Action::OFK_HIP) &&
@@ -4939,8 +4934,8 @@ Action *Driver::BuildOffloadingActions(Compilation &C,
   bool ShouldBundleHIP =
       Args.hasFlag(options::OPT_gpu_bundle_output,
                    options::OPT_no_gpu_bundle_output, false) ||
-      (HIPNoRDC && offloadDeviceOnly() &&
-       llvm::none_of(OffloadActions, [](Action *A) {
+      (!Args.getLastArg(options::OPT_no_gpu_bundle_output) && HIPNoRDC &&
+       offloadDeviceOnly() && llvm::none_of(OffloadActions, [](Action *A) {
          return A->getType() != types::TY_Image;
        }));
 
@@ -5113,8 +5108,13 @@ Action *Driver::ConstructPhaseAction(
           Args.hasArg(options::OPT_S) ? types::TY_LTO_IR : types::TY_LTO_BC;
       return C.MakeAction<BackendJobAction>(Input, Output);
     }
+
+    bool IsAMDGCNSPIRV = Input->getOffloadingToolChain() &&
+                         Input->getOffloadingToolChain()->getTriple().getOS() 
==
+                             llvm::Triple::OSType::AMDHSA &&
+                         
Input->getOffloadingToolChain()->getTriple().isSPIRV();
     if (Args.hasArg(options::OPT_emit_llvm) ||
-        TargetDeviceOffloadKind == Action::OFK_SYCL ||
+        TargetDeviceOffloadKind == Action::OFK_SYCL || IsAMDGCNSPIRV ||
         (((Input->getOffloadingToolChain() &&
            Input->getOffloadingToolChain()->getTriple().isAMDGPU()) ||
           TargetDeviceOffloadKind == Action::OFK_HIP) &&
@@ -5134,7 +5134,8 @@ Action *Driver::ConstructPhaseAction(
                    (TargetDeviceOffloadKind == Action::OFK_HIP &&
                     !Args.hasFlag(options::OPT_offload_new_driver,
                                   options::OPT_no_offload_new_driver,
-                                  C.isOffloadingHostKind(Action::OFK_Cuda))))
+                                  C.getActiveOffloadKinds() !=
+                                      Action::OFK_None)))
               ? types::TY_LLVM_IR
               : types::TY_LLVM_BC;
       return C.MakeAction<BackendJobAction>(Input, Output);
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 6eb77610079b7..91b5c85a26819 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4883,7 +4883,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
       (JA.isHostOffloading(C.getActiveOffloadKinds()) &&
        Args.hasFlag(options::OPT_offload_new_driver,
                     options::OPT_no_offload_new_driver,
-                    C.isOffloadingHostKind(Action::OFK_Cuda)));
+                    C.getActiveOffloadKinds() != Action::OFK_None));
 
   bool IsRDCMode =
       Args.hasFlag(options::OPT_fgpu_rdc, options::OPT_fno_gpu_rdc, false);
@@ -5248,7 +5248,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
       if (IsDeviceOffloadAction && !JA.isDeviceOffloading(Action::OFK_OpenMP) 
&&
           !Args.hasFlag(options::OPT_offload_new_driver,
                         options::OPT_no_offload_new_driver,
-                        C.isOffloadingHostKind(Action::OFK_Cuda)) &&
+                        C.getActiveOffloadKinds() != Action::OFK_None) &&
           !Triple.isAMDGPU()) {
         D.Diag(diag::err_drv_unsupported_opt_for_target)
             << Args.getLastArg(options::OPT_foffload_lto,
@@ -6721,7 +6721,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
     CmdArgs.append({"--offload-new-driver", "-foffload-via-llvm"});
   } else if (Args.hasFlag(options::OPT_offload_new_driver,
                           options::OPT_no_offload_new_driver,
-                          C.isOffloadingHostKind(Action::OFK_Cuda))) {
+                          C.getActiveOffloadKinds() != Action::OFK_None)) {
     CmdArgs.push_back("--offload-new-driver");
   }
 
@@ -9115,6 +9115,7 @@ void LinkerWrapper::ConstructJob(Compilation &C, const 
JobAction &JA,
       OPT_fno_lto,
       OPT_flto,
       OPT_flto_partitions_EQ,
+      OPT_hipspv_pass_plugin_EQ,
       OPT_flto_EQ};
   const llvm::DenseSet<unsigned> LinkerOptions{OPT_mllvm, OPT_Zlinker_input};
   auto ShouldForward = [&](const llvm::DenseSet<unsigned> &Set, Arg *A) {
diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index e5075cbcaf660..bbfd362e49417 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -573,7 +573,9 @@ void darwin::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
                                   const InputInfoList &Inputs,
                                   const ArgList &Args,
                                   const char *LinkingOutput) const {
-  assert(Output.getType() == types::TY_Image && "Invalid linker output type.");
+  assert((Output.getType() == types::TY_Image ||
+          Output.getType() == types::TY_Object) &&
+         "Invalid linker output type.");
 
   // If the number of arguments surpasses the system limits, we will encode the
   // input files in a separate file, shortening the command line. To this end,
diff --git a/clang/test/Driver/cl-offload.cu b/clang/test/Driver/cl-offload.cu
index b05bf3b97b7eb..8f1200f173359 100644
--- a/clang/test/Driver/cl-offload.cu
+++ b/clang/test/Driver/cl-offload.cu
@@ -18,11 +18,10 @@
 // CUDA-SAME: "-Weverything"
 // CUDA: link
 
-// HIP: "-cc1" "-triple" "x86_64-pc-windows-msvc{{.*}}" "-aux-triple" 
"amdgcn-amd-amdhsa"
-// HIP-SAME: "-Weverything"
 // HIP: "-cc1" "-triple" "amdgcn-amd-amdhsa" "-aux-triple" 
"x86_64-pc-windows-msvc"
 // HIP-SAME: "-Weverything"
-// HIP: {{lld.* "-flavor" "gnu" "-m" "elf64_amdgpu"}}
+// HIP: "-cc1" "-triple" "x86_64-pc-windows-msvc{{.*}}" "-aux-triple" 
"amdgcn-amd-amdhsa"
+// HIP-SAME: "-Weverything"
 // HIP: {{link.* "amdhip64.lib"}}
 
 // CMake uses this option when finding packages for HIP, so
diff --git a/clang/test/Driver/cuda-arch-translation.cu 
b/clang/test/Driver/cuda-arch-translation.cu
index b4a521df2e6f5..232a2bb1114e3 100644
--- a/clang/test/Driver/cuda-arch-translation.cu
+++ b/clang/test/Driver/cuda-arch-translation.cu
@@ -66,7 +66,7 @@
 // CUDA-SAME: -m64
 // CUDA: fatbinary
 
-// HIP: clang-offload-bundler
+// HIP: clang-offload-packager
 
 // SM20:--image3=kind=elf,sm=20{{.*}}
 // SM21:--image3=kind=elf,sm=21{{.*}}
@@ -81,20 +81,20 @@
 // SM61:--image3=kind=elf,sm=61{{.*}}
 // SM62:--image3=kind=elf,sm=62{{.*}}
 // SM70:--image3=kind=elf,sm=70{{.*}}
-// 
GFX600:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx600
-// 
GFX601:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx601
-// 
GFX602:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx602
-// 
GFX700:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx700
-// 
GFX701:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx701
-// 
GFX702:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx702
-// 
GFX703:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx703
-// 
GFX704:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx704
-// 
GFX705:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx705
-// 
GFX801:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx801
-// 
GFX802:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx802
-// 
GFX803:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx803
-// 
GFX805:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx805
-// 
GFX810:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx810
-// 
GFX900:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx900
-// 
GFX902:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx902
-// 
SPIRV:-targets=host-x86_64-unknown-linux-gnu,hip-spirv64-amd-amdhsa--amdgcnspirv
+// GFX600:triple=amdgcn-amd-amdhsa,arch=gfx600
+// GFX601:triple=amdgcn-amd-amdhsa,arch=gfx601
+// GFX602:triple=amdgcn-amd-amdhsa,arch=gfx602
+// GFX700:triple=amdgcn-amd-amdhsa,arch=gfx700
+// GFX701:triple=amdgcn-amd-amdhsa,arch=gfx701
+// GFX702:triple=amdgcn-amd-amdhsa,arch=gfx702
+// GFX703:triple=amdgcn-amd-amdhsa,arch=gfx703
+// GFX704:triple=amdgcn-amd-amdhsa,arch=gfx704
+// GFX705:triple=amdgcn-amd-amdhsa,arch=gfx705
+// GFX801:triple=amdgcn-amd-amdhsa,arch=gfx801
+// GFX802:triple=amdgcn-amd-amdhsa,arch=gfx802
+// GFX803:triple=amdgcn-amd-amdhsa,arch=gfx803
+// GFX805:triple=amdgcn-amd-amdhsa,arch=gfx805
+// GFX810:triple=amdgcn-amd-amdhsa,arch=gfx810
+// GFX900:triple=amdgcn-amd-amdhsa,arch=gfx900
+// GFX902:triple=amdgcn-amd-amdhsa,arch=gfx902
+// SPIRV:triple=spirv64-amd-amdhsa,arch=amdgcnspirv
diff --git a/clang/test/Driver/dep-file-flag-with-multiple-offload-archs.hip 
b/clang/test/Driver/dep-file-flag-with-multiple-offload-archs.hip
index f17e56acfb7f7..557f6925d23f9 100644
--- a/clang/test/Driver/dep-file-flag-with-multiple-offload-archs.hip
+++ b/clang/test/Driver/dep-file-flag-with-multiple-offload-archs.hip
@@ -1,12 +1,9 @@
 // RUN: %clang -### -nogpuinc -nogpulib --offload-arch=gfx1030 
--offload-arch=gfx1100 --offload-arch=gfx1101 --target=x86_64-linux-gnu -MD -MF 
tmp.d %s 2>&1 | FileCheck %s
 
 // CHECK-NOT: {{.*}}clang{{.*}}"-target-cpu" "gfx1030"{{.*}}"-dependency-file" 
"tmp.d"
-// CHECK: {{.*}}lld{{.*}}"-plugin-opt=mcpu=gfx1030"
 // CHECK-NOT: {{.*}}clang{{.*}}"-target-cpu" "gfx1100"{{.*}}"-dependency-file" 
"tmp.d"
-// CHECK: {{.*}}lld{{.*}}"-plugin-opt=mcpu=gfx1100"
 // CHECK-NOT: {{.*}}clang{{.*}}"-target-cpu" "gfx1101"{{.*}}"-dependency-file" 
"tmp.d"
-// CHECK: {{.*}}lld{{.*}}"-plugin-opt=mcpu=gfx1101"
-// CHECK: {{.*}}clang-offload-bundler
+// CHECK: {{.*}}clang-offload-packager
 // CHECK: {{.*}}clang{{.*}}"-target-cpu"{{.*}}"-dependency-file" "tmp.d"
 
 void main(){}
diff --git a/clang/test/Driver/hip-code-object-version.hip 
b/clang/test/Driver/hip-code-object-version.hip
index 6767c27761d0a..d4887609f4547 100644
--- a/clang/test/Driver/hip-code-object-version.hip
+++ b/clang/test/Driver/hip-code-object-version.hip
@@ -7,7 +7,6 @@
 
 // V4: "-mcode-object-version=4"
 // V4: "-mllvm" "--amdhsa-code-object-version=4"
-// V4: "-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx906"
 
 // Check bundle ID for code object version 5.
 
@@ -18,7 +17,6 @@
 
 // V5: "-mcode-object-version=5"
 // V5: "-mllvm" "--amdhsa-code-object-version=5"
-// V5: "-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx906"
 
 // Check bundle ID for code object version 6.
 
@@ -29,11 +27,10 @@
 
 // V6: "-mcode-object-version=6"
 // V6: "-mllvm" "--amdhsa-code-object-version=6"
-// V6: "-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx906"
 
 // Check bundle ID for code object version default
 
-// RUN: %clang -### --target=x86_64-linux-gnu \
+// RUN: %clang -### --target=x86_64-linux-gnu --no-offload-new-driver \
 // RUN:   --offload-arch=gfx906 -nogpuinc -nogpulib \
 // RUN:   %s 2>&1 | FileCheck -check-prefix=VD %s
 
diff --git a/clang/test/Driver/hip-gz-options.hip 
b/clang/test/Driver/hip-gz-options.hip
index 36de8e8404020..6d2709a172784 100644
--- a/clang/test/Driver/hip-gz-options.hip
+++ b/clang/test/Driver/hip-gz-options.hip
@@ -1,14 +1,13 @@
 // REQUIRES: zlib
 
 // RUN: %clang -### --target=x86_64-unknown-linux-gnu \
-// RUN:    --offload-arch=gfx906 %s -nogpulib -nogpuinc \
+// RUN:   --offload-arch=gfx906 %s -nogpulib -nogpuinc \
 // RUN:   -ggdb -gz=zlib 2>&1 | FileCheck %s
 
 // RUN: %clang -### --target=x86_64-unknown-linux-gnu \
 // RUN:   -fgpu-rdc --offload-arch=gfx906 %s -nogpulib -nogpuinc \
 // RUN:   -ggdb -gz=zlib 2>&1 | FileCheck %s
 
-// CHECK-DAG: {{".*clang(-[0-9]+)?(.exe)?" .* 
"--compress-debug-sections=zlib"}}
-// CHECK-DAG: {{".*lld(.exe)?" .* "--compress-debug-sections=zlib"}}
-// CHECK-DAG: {{".*clang(-[0-9]+)?(.exe)?" .* 
"--compress-debug-sections=zlib"}}
+// CHECK-DAG: {{".*clang(-[0-9]+)?(.exe)?" .* "-triple" "amdgcn-amd-amdhsa" .* 
"--compress-debug-sections=zlib"}}
+// CHECK-DAG: {{".*clang(-[0-9]+)?(.exe)?" .* "-triple" 
"x86_64-unknown-linux-gnu".* "--compress-debug-sections=zlib"}}
 // CHECK: "--compress-debug-sections=zlib"
diff --git a/clang/test/Driver/hip-macros.hip b/clang/test/Driver/hip-macros.hip
index bd93f9985a774..60456969c0e92 100644
--- a/clang/test/Driver/hip-macros.hip
+++ b/clang/test/Driver/hip-macros.hip
@@ -71,8 +71,6 @@
 // RUN: %clang -E -dM --offload-arch=gfx942 --cuda-device-only -nogpuinc 
-nogpulib \
 // RUN:   %s 2>&1 | FileCheck --check-prefixes=NOPTS %s
 // PTS-DAG: #define __HIP_API_PER_THREAD_DEFAULT_STREAM__ 1
-// PTS-DAG: #define __HIP_API_PER_THREAD_DEFAULT_STREAM__ 1
-// PTS-DAG: #define HIP_API_PER_THREAD_DEFAULT_STREAM 1
 // PTS-DAG: #define HIP_API_PER_THREAD_DEFAULT_STREAM 1
 // NOPTS-NOT: #define __HIP_API_PER_THREAD_DEFAULT_STREAM__
 // NOPTS-NOT: #define HIP_API_PER_THREAD_DEFAULT_STREAM
@@ -83,4 +81,3 @@
 // RUN:   %s 2>&1 | FileCheck --check-prefix=APPROX %s
 // NOAPPROX-NOT: #define __CLANG_GPU_APPROX_TRANSCENDENTALS__
 // APPROX: #define __CLANG_GPU_APPROX_TRANSCENDENTALS__ 1
-// APPROX: #define __CLANG_GPU_APPROX_TRANSCENDENTALS__ 1
diff --git a/clang/test/Driver/hip-offload-arch.hip 
b/clang/test/Driver/hip-offload-arch.hip
index dd65a0e103ec6..1af53baf63da7 100644
--- a/clang/test/Driver/hip-offload-arch.hip
+++ b/clang/test/Driver/hip-offload-arch.hip
@@ -4,5 +4,5 @@
 // RUN:   -nogpuinc -nogpulib \
 // RUN:   %s 2>&1 | FileCheck %s
 
-// CHECK: {{"[^"]*clang[^"]*".* "-target-cpu" "gfx1030"}}
-// CHECK: {{"[^"]*clang[^"]*".* "-target-cpu" "gfx1031"}}
+// CHECK: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx1030"
+// CHECK: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx1031"
diff --git a/clang/test/Driver/hip-options.hip 
b/clang/test/Driver/hip-options.hip
index 6206020d76db6..e15e04194ffab 100644
--- a/clang/test/Driver/hip-options.hip
+++ b/clang/test/Driver/hip-options.hip
@@ -83,16 +83,12 @@
 // RUN:   --cuda-gpu-arch=gfx906 -foffload-lto=thin -fwhole-program-vtables %s 
2>&1 \
 // RUN:   | FileCheck -check-prefix=HIPTHINLTO %s
 
-// RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
-// RUN:   --cuda-gpu-arch=gfx906 -fgpu-rdc -foffload-lto=thin 
-fwhole-program-vtables %s 2>&1 \
-// RUN:   | FileCheck -check-prefix=HIPTHINLTO %s
-
 // Ensure we don't error about -fwhole-program-vtables for the non-device 
offload compile.
 // HIPTHINLTO-NOT: error: invalid argument '-fwhole-program-vtables' only 
allowed with '-flto'
 // HIPTHINLTO-NOT: "-cc1"{{.*}} "-triple" "x86_64-unknown-linux-gnu" {{.*}} 
"-flto-unit"
 // HIPTHINLTO: "-cc1"{{.*}} "-triple" "amdgcn-amd-amdhsa" {{.*}} "-flto=thin" 
"-flto-unit" {{.*}} "-fwhole-program-vtables"
 // HIPTHINLTO-NOT: "-cc1"{{.*}} "-triple" "x86_64-unknown-linux-gnu" {{.*}} 
"-flto-unit"
-// HIPTHINLTO: lld{{.*}}"-plugin-opt=mcpu=gfx906" "-plugin-opt=thinlto" 
"-plugin-opt=-force-import-all"
+// HIPTHINLTO: clang-linker-wrapper{{.*}} 
"--device-compiler=amdgcn-amd-amdhsa=-flto=thin"
 
 // Check that -flto=thin is handled correctly, particularly with 
-fwhole-program-vtables.
 //
@@ -120,10 +116,7 @@
 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
 // RUN:   --cuda-gpu-arch=gfx906 -fgpu-rdc -Xoffload-linker --build-id=md5 %s 
2>&1 \
 // RUN:   | FileCheck -check-prefix=OFL-LINK %s
-// RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
-// RUN:   --cuda-gpu-arch=gfx906 -Xoffload-linker --build-id=md5 %s 2>&1 \
-// RUN:   | FileCheck -check-prefix=OFL-LINK %s
-// OFL-LINK: lld{{.*}}"--build-id=md5"
+// OFL-LINK: clang-linker-wrapper{{.*}}"--device-linker=--build-id=md5"
 
 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
 // RUN:   --offload-arch=gfx906 -fhip-kernel-arg-name %s 2>&1 \
diff --git a/clang/test/Driver/hip-sanitize-options.hip 
b/clang/test/Driver/hip-sanitize-options.hip
index 0c9c15b61fdc9..8e7e5e3986fb6 100644
--- a/clang/test/Driver/hip-sanitize-options.hip
+++ b/clang/test/Driver/hip-sanitize-options.hip
@@ -56,8 +56,8 @@
 // NORDC-NOT: {{"[^"]*lld(\.exe){0,1}".*}} "[[OUT]]" {{".*asanrtl.bc" 
".*hip.bc"}}
 // NORDC: {{"[^"]*clang[^"]*".* "-triple" "x86_64-unknown-linux-gnu".* 
"-fsanitize=address"}}
 
-// RDC: {{"[^"]*clang[^"]*".* "-triple" "x86_64-unknown-linux-gnu".* 
"-fsanitize=address"}}
 // RDC: {{"[^"]*clang[^"]*".* "-emit-llvm-bc".* "-fcuda-is-device".* 
"-mlink-bitcode-file" ".*asanrtl.bc".* "-fsanitize=address".*}} "-o" 
"[[OUT:[^"]*.bc]]"
+// RDC: {{"[^"]*clang[^"]*".* "-triple" "x86_64-unknown-linux-gnu".* 
"-fsanitize=address"}}
 // RDC-NOT: {{"[^"]*lld(\.exe){0,1}".*}} "[[OUT]]" {{".*asanrtl.bc" 
".*hip.bc"}}
 
 // FAIL: error: cannot find ROCm device library for ABI version 5; provide its 
path via '--rocm-path' or '--rocm-device-lib-path', or pass '-nogpulib' to 
build without ROCm device library
diff --git a/clang/test/Driver/hip-save-temps.hip 
b/clang/test/Driver/hip-save-temps.hip
index 142c3f1611a36..2e8489f65d7e0 100644
--- a/clang/test/Driver/hip-save-temps.hip
+++ b/clang/test/Driver/hip-save-temps.hip
@@ -1,31 +1,31 @@
 // -fno-gpu-rdc without -o with -c
 // RUN: %clang -### --target=x86_64-linux-gnu -nogpulib -save-temps \
-// RUN:   -nogpuinc --offload-arch=gfx900 -c %s 2>&1 | \
+// RUN:   --no-offload-new-driver -nogpuinc --offload-arch=gfx900 -c %s 2>&1 | 
\
 // RUN:   FileCheck -check-prefixes=CHECK,NORDC %s
 
 // -fno-gpu-rdc without -o
 // RUN: %clang -### --target=x86_64-linux-gnu -nogpulib -save-temps \
-// RUN:   -nogpuinc --offload-arch=gfx900 %s 2>&1 | \
+// RUN:   --no-offload-new-driver -nogpuinc --offload-arch=gfx900 %s 2>&1 | \
 // RUN:   FileCheck -check-prefixes=CHECK,NORDC,NOUT %s
 
 // -fno-gpu-rdc with -o
 // RUN: %clang -### --target=x86_64-linux-gnu -nogpulib -save-temps \
-// RUN:   -nogpuinc -o executable --offload-arch=gfx900 %s 2>&1 | \
+// RUN:   --no-offload-new-driver -nogpuinc -o executable 
--offload-arch=gfx900 %s 2>&1 | \
 // RUN:   FileCheck -check-prefixes=CHECK,NORDC,WOUT %s
 
 // -fgpu-rdc without -o with -c
 // RUN: %clang -### --target=x86_64-linux-gnu -nogpulib -save-temps \
-// RUN:   -nogpuinc -fgpu-rdc --offload-arch=gfx900 -c %s 2>&1 | \
+// RUN:   --no-offload-new-driver -nogpuinc -fgpu-rdc --offload-arch=gfx900 -c 
%s 2>&1 | \
 // RUN:   FileCheck -check-prefixes=CHECK,RDC,RDCC %s
 
 // -fgpu-rdc without -o
 // RUN: %clang -### --target=x86_64-linux-gnu -nogpulib -save-temps \
-// RUN:   -nogpuinc -fgpu-rdc --offload-arch=gfx900 %s 2>&1 | \
+// RUN:   --no-offload-new-driver -nogpuinc -fgpu-rdc --offload-arch=gfx900 %s 
2>&1 | \
 // RUN:   FileCheck -check-prefixes=CHECK,RDC,RDCL,NOUT %s
 
 // -fgpu-rdc with -o
 // UN: %clang -### --target=x86_64-linux-gnu -nogpulib -save-temps \
-// UN:   -nogpuinc -o executable -fgpu-rdc --offload-arch=gfx900 %s 2>&1 | \
+// UN:   --offload-new-driver -nogpuinc -o executable -fgpu-rdc 
--offload-arch=gfx900 %s 2>&1 | \
 // UN:   FileCheck -check-prefixes=CHECK,RDC,RDCL,WOUT %s
 
 // -fgpu-rdc host object path
diff --git a/clang/test/Driver/hip-thinlto.hip 
b/clang/test/Driver/hip-thinlto.hip
index bcb7d4e6cb52e..53fd0485cb16b 100644
--- a/clang/test/Driver/hip-thinlto.hip
+++ b/clang/test/Driver/hip-thinlto.hip
@@ -1,9 +1,9 @@
 // RUN: %clang -foffload-lto=thin -nogpulib -nogpuinc %s -### 2>&1 | FileCheck 
%s
 
-// CHECK: -plugin-opt=thinlto
-// CHECK-SAME: -plugin-opt=-force-import-all
-// CHECK-SAME: -plugin-opt=-avail-extern-to-local
-// CHECK-SAME: -plugin-opt=-avail-extern-gv-in-addrspace-to-local=3
+// CHECK: "--device-compiler=amdgcn-amd-amdhsa=-flto=thin"
+// CHECK-SAME: 
"--device-linker=amdgcn-amd-amdhsa=-plugin-opt=-force-import-all"
+// CHECK-SAME: 
"--device-linker=amdgcn-amd-amdhsa=-plugin-opt=-avail-extern-to-local"
+// CHECK-SAME: 
"--device-linker=amdgcn-amd-amdhsa=-plugin-opt=-avail-extern-gv-in-addrspace-to-local=3"
 int main(int, char *[]) {
   return 0;
 }
diff --git a/clang/test/Driver/hip-toolchain-device-only.hip 
b/clang/test/Driver/hip-toolchain-device-only.hip
index 12097819f6688..c0621854f17ce 100644
--- a/clang/test/Driver/hip-toolchain-device-only.hip
+++ b/clang/test/Driver/hip-toolchain-device-only.hip
@@ -21,7 +21,3 @@
 
 // CHECK: [[LLD]] "-flavor" "gnu" "-m" "elf64_amdgpu" "--no-undefined" 
"-shared"
 // CHECK-SAME: "-o" "[[IMG_DEV_A_900:.*out]]" [[OBJ_DEV_A_900]]
-
-// CHECK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
-// CHECK-SAME: 
"-targets={{.*}},hip{{.*}}-amdgcn-amd-amdhsa--gfx803,hip{{.*}}-amdgcn-amd-amdhsa--gfx900"
-// CHECK-SAME: "-input={{.*}}" "-input=[[IMG_DEV_A_803]]" 
"-input=[[IMG_DEV_A_900]]" "-output=[[BUNDLE_A:.*hipfb]]"
diff --git a/clang/test/Driver/hip-toolchain-mllvm.hip 
b/clang/test/Driver/hip-toolchain-mllvm.hip
index 33018cc398915..bedb053b9006c 100644
--- a/clang/test/Driver/hip-toolchain-mllvm.hip
+++ b/clang/test/Driver/hip-toolchain-mllvm.hip
@@ -30,13 +30,11 @@
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: {{.*}} "-target-cpu" "gfx803"
 // CHECK-SAME: {{.*}} "-mllvm" "-unroll-count=10" {{.*}}
-// CHECK: [[LLD:".*lld.*"]] {{.*}}"-m" "elf64_amdgpu"{{.*}} 
"-plugin-opt=-unroll-count=10"{{.*}} "-plugin-opt=-inline-threshold=100"
 
 // CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: {{.*}} "-target-cpu" "gfx900"
 // CHECK-SAME: {{.*}} "-mllvm" "-unroll-count=10" {{.*}}
-// CHECK: [[LLD:".*lld.*"]] {{.*}} "-plugin-opt=-unroll-count=10"{{.*}} 
"-plugin-opt=-inline-threshold=100"
 
 // NEG-NOT: {{".*opt"}}
 // NEG-NOT: {{".*llc"}}
diff --git a/clang/test/Driver/hip-toolchain-no-rdc.hip 
b/clang/test/Driver/hip-toolchain-no-rdc.hip
index ddd251b67cc57..0bc9cc45afb25 100644
--- a/clang/test/Driver/hip-toolchain-no-rdc.hip
+++ b/clang/test/Driver/hip-toolchain-no-rdc.hip
@@ -4,7 +4,7 @@
 // RUN:   --hip-device-lib=lib1.bc --hip-device-lib=lib2.bc \
 // RUN:   --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib1 \
 // RUN:   --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib2 \
-// RUN:   -fuse-ld=lld -B%S/Inputs/lld -nogpuinc \
+// RUN:   -fuse-ld=lld -B%S/Inputs/lld -nogpuinc --no-offload-new-driver \
 // RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
 // RUN: 2>&1 | FileCheck -check-prefixes=CHECK,LINK,OLD %s
@@ -14,7 +14,7 @@
 // RUN:   --hip-device-lib=lib1.bc --hip-device-lib=lib2.bc \
 // RUN:   --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib1 \
 // RUN:   --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib2 \
-// RUN:   -fuse-ld=lld -B%S/Inputs/lld -nogpuinc -c \
+// RUN:   -fuse-ld=lld -B%S/Inputs/lld -nogpuinc -c --no-offload-new-driver \
 // RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
 // RUN: 2>&1 | FileCheck -check-prefixes=CHECK,OLD %s
@@ -36,11 +36,16 @@
 // RUN:   %t/a.o %t/b.o \
 // RUN: 2>&1 | FileCheck -check-prefixes=LKONLY %s
 
-// RUN: %clang -### --target=x86_64-linux-gnu \
+// RUN: %clang -### --target=x86_64-linux-gnu --no-offload-new-driver \
 // RUN:   --offload-arch=amdgcnspirv --offload-arch=gfx900 \
 // RUN:   %s -nogpuinc -nogpulib \
 // RUN: 2>&1 | FileCheck -check-prefixes=AMDGCNSPIRV %s
 
+// RUN: %clang -### --target=x86_64-linux-gnu --offload-new-driver \
+// RUN:   --offload-arch=amdgcnspirv --offload-arch=gfx900 \
+// RUN:   %s -nogpuinc -nogpulib \
+// RUN: 2>&1 | FileCheck -check-prefixes=AMDGCNSPIRV-NEW %s
+
 //
 // Compile device code in a.cu to code object for gfx803.
 //
@@ -214,3 +219,4 @@
 // AMDGCNSPIRV: {{".*clang-offload-bundler.*"}} "-type=o"
 // AMDGCNSPIRV-SAME: 
"-targets={{.*}}hipv4-spirv64-amd-amdhsa--amdgcnspirv,hipv4-amdgcn-amd-amdhsa--gfx900"
 // AMDGCNSPIRV-SAME: "-input=[[AMDGCNSPV_CO]]" "-input=[[GFX900_CO]]"
+// AMDGCNSPIRV-NEW: "-cc1" "-triple" "spirv64-amd-amdhsa" 
{{.*}}"-emit-llvm-bc" {{.*}} "-o" "[[AMDGCNSPV_BC:.*bc]]"
diff --git a/clang/test/Driver/hip-toolchain-opt.hip 
b/clang/test/Driver/hip-toolchain-opt.hip
index b104f6fff2034..bb033717deada 100644
--- a/clang/test/Driver/hip-toolchain-opt.hip
+++ b/clang/test/Driver/hip-toolchain-opt.hip
@@ -74,30 +74,6 @@
 // O0-CGO2-SAME: "-O0"
 // O0-CGO2-NOT: "--lto-CGO2"
 
-// ALL-NOT: "{{.*}}opt"
-
-// ALL-NOT: "{{.*}}llc"
-
-// ALL: "{{.*}}lld{{.*}}" {{.*}} "-plugin-opt=mcpu=gfx900"
-// DEFAULT-NOT: "-plugin-opt=O{{.*}}"
-// O0-SAME: "-plugin-opt=O0"
-// O0-SAME: "--lto-CGO0"
-// O1-SAME: "-plugin-opt=O1"
-// O1-SAME: "--lto-CGO1"
-// O2-SAME: "-plugin-opt=O2"
-// O2-SAME: "--lto-CGO2"
-// O3-SAME: "-plugin-opt=O3"
-// O3-SAME: "--lto-CGO3"
-// Os-SAME: "-plugin-opt=O2"
-// Os-SAME: "--lto-CGO2"
-// Oz-SAME: "-plugin-opt=O2"
-// Oz-SAME: "--lto-CGO2"
-// Og-SAME: "-plugin-opt=O1"
-// Og-SAME: "--lto-CGO1"
-// O0-CGO2-SAME: "-plugin-opt=O0"
-// O0-CGO2-SAME: "--lto-CGO0"
-// O0-CGO2-SAME: "--lto-CGO2"
-
 // ALL: "-cc1" "-triple" "x86_64-unknown-linux-gnu"
 // DEFAULT-NOT: "-O{{.}}"
 // O0-SAME: "-O0"
@@ -109,3 +85,14 @@
 // Og-SAME: "-Og"
 // O0-CGO2-SAME: "-O0"
 // O0-CGO2-NOT: "--lto-CGO2"
+
+// ALL: "{{.*}}clang-linker-wrapper{{.*}}" "--should-extract=gfx900"
+// DEFAULT-NOT: "--device-compiler=amdgcn-amd-amdhsa=-O{{.*}}"
+// O0-SAME: "--device-compiler=amdgcn-amd-amdhsa=-O0"
+// O1-SAME: "--device-compiler=amdgcn-amd-amdhsa=-O1"
+// O2-SAME: "--device-compiler=amdgcn-amd-amdhsa=-O2"
+// O3-SAME: "--device-compiler=amdgcn-amd-amdhsa=-O3"
+// Os-SAME: "--device-compiler=amdgcn-amd-amdhsa=-Os"
+// Oz-SAME: "--device-compiler=amdgcn-amd-amdhsa=-Oz"
+// Og-SAME: "--device-compiler=amdgcn-amd-amdhsa=-Og"
+// O0-CGO2-SAME: "--device-compiler=amdgcn-amd-amdhsa=-O0"
diff --git a/clang/test/Driver/hipspv-link-static-library.hip 
b/clang/test/Driver/hipspv-link-static-library.hip
index 03126ae589a09..49365cb75adca 100644
--- a/clang/test/Driver/hipspv-link-static-library.hip
+++ b/clang/test/Driver/hipspv-link-static-library.hip
@@ -9,13 +9,13 @@
 
 // Test that -l options are passed to llvm-link for --offload=spirv64
 // RUN: %clang -### --target=x86_64-linux-gnu --offload=spirv64 \
-// RUN:   --hip-path=%S/Inputs/hipspv -nohipwrapperinc %s \
+// RUN:   --no-offload-new-driver --hip-path=%S/Inputs/hipspv -nohipwrapperinc 
%s \
 // RUN:   -L%t -lSDL \
 // RUN: 2>&1 | FileCheck -check-prefix=SDL-LINK %s
 
 // Test that .a files are properly unbundled and passed to llvm-link  
 // RUN: %clang -### --target=x86_64-linux-gnu --offload=spirv64 \
-// RUN:   --hip-path=%S/Inputs/hipspv -nohipwrapperinc %s \
+// RUN:   --no-offload-new-driver --hip-path=%S/Inputs/hipspv -nohipwrapperinc 
%s \
 // RUN:   %t/libSDL.a \
 // RUN: 2>&1 | FileCheck -check-prefix=SDL-ARCHIVE %s
 
diff --git a/clang/test/Driver/hipspv-pass-plugin.hip 
b/clang/test/Driver/hipspv-pass-plugin.hip
index fc3c64b057352..de6e07b57bd6f 100644
--- a/clang/test/Driver/hipspv-pass-plugin.hip
+++ b/clang/test/Driver/hipspv-pass-plugin.hip
@@ -1,19 +1,19 @@
 // UNSUPPORTED: system-windows
 
 // RUN: %clang -### -target x86_64-linux-gnu --offload=spirv64 \
-// RUN:  --hip-path=%S/Inputs/hipspv -nogpuinc %s \
+// RUN: --no-offload-new-driver --hip-path=%S/Inputs/hipspv -nogpuinc %s \
 // RUN: 2>&1 | FileCheck --check-prefixes=FROM-HIP-PATH %s
 
 // RUN: %clang -### -target x86_64-linux-gnu --offload=spirv64 \
-// RUN: -nogpuinc -nogpulib --hipspv-pass-plugin=%S/Inputs/pass-plugin.so %s \
+// RUN: --no-offload-new-driver -nogpuinc -nogpulib 
--hipspv-pass-plugin=%S/Inputs/pass-plugin.so %s \
 // RUN: 2>&1 | FileCheck --check-prefixes=FROM-OPTION %s
 
 // RUN: not %clang -### --target=x86_64-linux-gnu --offload=spirv64 \
-// RUN: -nogpuinc -nogpulib --hipspv-pass-plugin=foo.so %s \
+// RUN: --no-offload-new-driver -nogpuinc -nogpulib 
--hipspv-pass-plugin=foo.so %s \
 // RUN: 2>&1 | FileCheck --check-prefixes=FROM-OPTION-INVALID %s
 
 // RUN: %clang -### -target x86_64-linux-gnu --offload=spirv64 \
-// RUN: -nogpuinc -nogpulib %s \
+// RUN: --no-offload-new-driver -nogpuinc -nogpulib %s \
 // RUN: 2>&1 | FileCheck --check-prefixes=NO-PLUGIN %s
 
 // FROM-HIP-PATH: {{".*opt"}} {{".*.bc"}} "-load-pass-plugin"
diff --git a/clang/test/Driver/hipspv-toolchain.hip 
b/clang/test/Driver/hipspv-toolchain.hip
index 3c175ebf433cc..76997a27e4065 100644
--- a/clang/test/Driver/hipspv-toolchain.hip
+++ b/clang/test/Driver/hipspv-toolchain.hip
@@ -41,7 +41,7 @@
 // RUN:   && chmod +x %t/versioned/llvm-spirv-%llvm-version-major
 // RUN: env "PATH=%t/versioned" %clang -### -target x86_64-linux-gnu \
 // RUN:   --offload=spirv64 --hip-path=%S/Inputs/hipspv -nohipwrapperinc \
-// RUN:   %s 2>&1 \
+// RUN:   --no-offload-new-driver %s 2>&1 \
 // RUN:   | FileCheck -DVERSION=%llvm-version-major \
 // RUN:   --check-prefix=VERSIONED %s
 
diff --git a/clang/unittests/Tooling/ToolingTest.cpp 
b/clang/unittests/Tooling/ToolingTest.cpp
index 25e1d67eb2294..53b5140fdbdb6 100644
--- a/clang/unittests/Tooling/ToolingTest.cpp
+++ b/clang/unittests/Tooling/ToolingTest.cpp
@@ -443,9 +443,9 @@ TEST_F(CommandLineExtractorTest, AcceptOffloadingCompile) {
 TEST_F(CommandLineExtractorTest, AcceptOffloadingSyntaxOnly) {
   addFile("test.c", "int main() {}\n");
   const char *Args[] = {
-      "clang",         "-target",   "arm64-apple-macosx11.0.0",
-      "-fsyntax-only", "-x",        "hip",
-      "test.c",        "-nogpulib", "-nogpuinc"};
+      "clang",     "-target",  "arm64-apple-macosx11.0.0", "-fsyntax-only",
+      "-x",        "hip",      "--no-offload-new-driver",  "test.c",
+      "-nogpulib", "-nogpuinc"};
   EXPECT_NE(extractCC1Arguments(Args), nullptr);
 }
 

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to