Author: Joseph Huber
Date: 2026-07-01T09:28:51-05:00
New Revision: 525f5a1ded8c66e4a3dff82ed066df8cf6a67dae

URL: 
https://github.com/llvm/llvm-project/commit/525f5a1ded8c66e4a3dff82ed066df8cf6a67dae
DIFF: 
https://github.com/llvm/llvm-project/commit/525f5a1ded8c66e4a3dff82ed066df8cf6a67dae.diff

LOG: Revert "[HIP][AMDGPU] Use non-LTO pipeline for non-RDC in the linker 
wrapper (#201135)" (#206961)

I believe I fixed the immediate issues that were causing regressions
with this, and now this is leading to its own regressions in building
Pytorch apparently. This was explicitly marked as a hack, and this
should resolve an ongoing issue so we should revert this for now.

Should fix LCOMPILER-2396

This reverts commit eaff67c9838f98d221aa563c9e5d4e714d636674.

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/Clang.cpp
    clang/test/Driver/hip-toolchain-no-rdc.hip
    clang/test/OffloadTools/clang-linker-wrapper/linker-wrapper-hip-no-rdc.c
    clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
    clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td

Removed: 
    
clang/test/OffloadTools/clang-linker-wrapper/linker-wrapper-hip-no-rdc-amdgcnspirv.c


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index d776f607fd709..93a4f5d83873b 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -9910,19 +9910,6 @@ void LinkerWrapper::ConstructJob(Compilation &C, const 
JobAction &JA,
           }
         }
       }
-
-      if (JA.getType() == types::TY_HIP_FATBIN && Kind == Action::OFK_HIP) {
-        // Non-RDC HIP uses the conventional non-LTO pipeline unless the user
-        // opts into offload LTO.
-        bool UsesProfileGenerate = Args.hasArg(
-            options::OPT_fprofile_generate, options::OPT_fprofile_generate_EQ,
-            options::OPT_fprofile_instr_generate,
-            options::OPT_fprofile_instr_generate_EQ);
-        if (!Args.hasArg(options::OPT_foffload_lto_EQ,
-                         options::OPT_fno_offload_lto) &&
-            !UsesProfileGenerate && !TC->getTriple().isSPIRV())
-          CmdArgs.push_back("--no-lto");
-      }
     }
   }
 

diff  --git a/clang/test/Driver/hip-toolchain-no-rdc.hip 
b/clang/test/Driver/hip-toolchain-no-rdc.hip
index 6f148ce01ff30..465722121fc67 100644
--- a/clang/test/Driver/hip-toolchain-no-rdc.hip
+++ b/clang/test/Driver/hip-toolchain-no-rdc.hip
@@ -46,21 +46,6 @@
 // RUN:   %s -nogpuinc -nogpulib \
 // RUN: 2>&1 | FileCheck -check-prefixes=AMDGCNSPIRV-NEW %s
 
-// SPIR-V requires the LTO pipeline; --no-lto must not be passed.
-// RUN: %clang -### --target=x86_64-linux-gnu -fno-gpu-rdc \
-// RUN:   --offload-arch=amdgcnspirv -nogpuinc -nogpulib \
-// RUN:   %s 2>&1 | FileCheck -check-prefixes=SPIRV-NO-LTO %s
-// SPIRV-NO-LTO: {{".*clang-linker-wrapper}}
-// SPIRV-NO-LTO-NOT: "--no-lto"
-// SPIRV-NO-LTO-SAME: "--emit-fatbin-only"
-
-// Profile generation needs LTO, so the linker wrapper must not get --no-lto.
-// RUN: %clang -### --target=x86_64-linux-gnu -fno-gpu-rdc -fprofile-generate \
-// RUN:   -x hip --cuda-gpu-arch=gfx900 -nogpuinc -nogpulib 
--offload-new-driver \
-// RUN:   %s 2>&1 | FileCheck -check-prefixes=PGO 
-implicit-check-not="--no-lto" %s
-// PGO: {{".*clang-linker-wrapper}}
-// PGO-SAME: "--emit-fatbin-only"
-
 //
 // Compile device code in a.cu to code object for gfx803.
 //
@@ -123,7 +108,6 @@
 
 // NEW: [[WRAPPER:".*clang-linker-wrapper]]"
 // NEW-SAME: "--device-compiler=amdgcn-amd-amdhsa=-flto=full"
-// NEW-SAME: "--no-lto"
 // NEW-SAME: "--host-triple=x86_64-unknown-linux-gnu"
 // NEW-SAME: "--emit-fatbin-only"
 // NEW-SAME: "-o" "[[HIPFB_A:.*.hipfb]]" "[[PACKAGE_A]]"
@@ -198,7 +182,6 @@
 
 // NEW: [[WRAPPER:".*clang-linker-wrapper]]"
 // NEW-SAME: "--device-compiler=amdgcn-amd-amdhsa=-flto=full"
-// NEW-SAME: "--no-lto"
 // NEW-SAME: "--emit-fatbin-only"
 // NEW-SAME: "-o" "[[HIPFB_B:.*.hipfb]]" "[[PACKAGE_B]]"
 

diff  --git 
a/clang/test/OffloadTools/clang-linker-wrapper/linker-wrapper-hip-no-rdc-amdgcnspirv.c
 
b/clang/test/OffloadTools/clang-linker-wrapper/linker-wrapper-hip-no-rdc-amdgcnspirv.c
deleted file mode 100644
index 205735f730cb9..0000000000000
--- 
a/clang/test/OffloadTools/clang-linker-wrapper/linker-wrapper-hip-no-rdc-amdgcnspirv.c
+++ /dev/null
@@ -1,23 +0,0 @@
-// REQUIRES: amdgpu-registered-target
-// REQUIRES: spirv-registered-target
-
-// In a mixed non-RDC HIP compile, a global --no-lto must drive the concrete
-// arch onto the non-LTO pipeline while being ignored for SPIR-V.
-
-// RUN: %clang -cc1 %s -triple amdgcn-amd-amdhsa -emit-llvm-bc -o %t.amdgpu.bc
-// RUN: %clang -cc1 %s -triple spirv64-amd-amdhsa -emit-llvm-bc -o %t.spirv.bc
-// RUN: llvm-offload-binary -o %t.out \
-// RUN:   
--image=file=%t.amdgpu.bc,kind=hip,triple=amdgcn-amd-amdhsa,arch=gfx1200 \
-// RUN:   
--image=file=%t.spirv.bc,kind=hip,triple=spirv64-amd-amdhsa,arch=amdgcnspirv
-
-// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run 
--no-lto \
-// RUN:   --emit-fatbin-only --linker-path=/usr/bin/ld %t.out -o %t.hipfb 2>&1 
\
-// RUN: | FileCheck %s
-
-// The concrete arch honors --no-lto
-// CHECK: clang{{.*}} --target=amdgcn-amd-amdhsa -mcpu=gfx1200 {{.*}}-x ir 
{{.*}}-flto=none
-
-// SPIR-V ignores the leaked --no-lto
-// CHECK: clang{{.*}} --target=spirv64-amd-amdhsa -march=amdgcnspirv
-// CHECK-NOT: -x ir
-// CHECK-NOT: -flto=none

diff  --git 
a/clang/test/OffloadTools/clang-linker-wrapper/linker-wrapper-hip-no-rdc.c 
b/clang/test/OffloadTools/clang-linker-wrapper/linker-wrapper-hip-no-rdc.c
index 80ac493825aad..aae330bd3f6de 100644
--- a/clang/test/OffloadTools/clang-linker-wrapper/linker-wrapper-hip-no-rdc.c
+++ b/clang/test/OffloadTools/clang-linker-wrapper/linker-wrapper-hip-no-rdc.c
@@ -55,15 +55,3 @@ __attribute__((visibility("protected"), used)) int x;
 // RUN: test -s %t.gfx9-4-generic-xnack+.co
 // RUN: test -f %t.gfx1200.co
 // RUN: test -s %t.gfx1200.co
-
-// Without --no-lto the AMDGPU device compilation uses the LTO pipeline
-// (-flto).
-// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu 
--wrapper-verbose --dry-run --emit-fatbin-only --linker-path=/usr/bin/ld %t.out 
-o %t.lto.hipfb 2>&1 | FileCheck %s --check-prefix=LTO
-// LTO: clang{{.*}} -mcpu=gfx1200
-
-// With --no-lto the AMDGPU device compilation uses the conventional non-LTO
-// pipeline: -flto must not be passed, and '-x ir' must be passed so Clang
-// compiles the bitcode (stored in an object-extension file) instead of
-// handing it to the LTO link.
-// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu 
--wrapper-verbose --dry-run --no-lto --emit-fatbin-only 
--linker-path=/usr/bin/ld %t.out -o %t.nolto.hipfb 2>&1 | FileCheck %s 
--check-prefix=NO-LTO
-// NO-LTO: clang{{.*}} -mcpu=gfx1200{{.*}} -x ir {{.*}}-flto=none

diff  --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index a4a67eed7d47f..76be0f776e561 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -543,16 +543,6 @@ Expected<StringRef> clang(ArrayRef<StringRef> InputFiles, 
const ArgList &Args,
   if (!Triple.isNVPTX() && !Triple.isSPIRV())
     CmdArgs.push_back("-Wl,--no-undefined");
 
-  // The device inputs are bitcode stored in files with an object extension.
-  // Force the IR input language so Clang runs the compile and backend phases
-  // instead of treating them as linker inputs, which would defer codegen to
-  // the LTO link and defeat the non-LTO pipeline.
-  // FIXME: This is a stop-gap for non-RDC. Longer term, RDC and non-RDC should
-  //        share a unified interface.
-  // SPIR-V has no non-LTO pipeline so a --no-lto leaked from a concrete arch 
in
-  // a multi-target compile is ignored. Which is a workaround to remove.
-  if (Args.hasArg(OPT_no_lto) && !Triple.isSPIRV())
-    CmdArgs.append({"-x", "ir"});
   for (StringRef InputFile : InputFiles)
     CmdArgs.push_back(InputFile);
 
@@ -615,9 +605,6 @@ Expected<StringRef> clang(ArrayRef<StringRef> InputFiles, 
const ArgList &Args,
   for (StringRef Arg : Args.getAllArgValues(OPT_compiler_arg_EQ))
     CmdArgs.push_back(Args.MakeArgString(Arg));
 
-  if (Args.hasArg(OPT_no_lto) && !Triple.isSPIRV())
-    CmdArgs.append({"-flto=none", "-Wno-unused-command-line-argument"});
-
   if (Error Err = executeCommands(*ClangPath, CmdArgs))
     return std::move(Err);
 

diff  --git a/clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td 
b/clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td
index 87a26ca90a66f..53b6c596de291 100644
--- a/clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td
+++ b/clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td
@@ -39,9 +39,6 @@ def print_wrapped_module : Flag<["--"], 
"print-wrapped-module">,
   HelpText<"Print the wrapped module's IR for testing">;
 def save_temps : Flag<["--"], "save-temps">,
   Flags<[WrapperOnlyOption]>, HelpText<"Save intermediate results">;
-def no_lto : Flag<["--"], "no-lto">,
-             Flags<[WrapperOnlyOption]>,
-             HelpText<"Use the non-LTO device compilation pipeline">;
 def compress : Flag<["--"], "compress">,
   Flags<[WrapperOnlyOption]>, HelpText<"Compress bundled files">;
 def compression_level_eq : Joined<["--"], "compression-level=">,


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to