[llvm] AMDGPU: Don't pad .text with s_code_end if it would otherwise be empty (PR #147980)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 10 18:47:10 PDT 2025


================
@@ -486,10 +486,12 @@ bool AMDGPUAsmPrinter::doFinalization(Module &M) {
   // Pad with s_code_end to help tools and guard against instruction prefetch
   // causing stale data in caches. Arguably this should be done by the linker,
   // which is why this isn't done for Mesa.
+  // Don't do it if there are no functions.
   const MCSubtargetInfo &STI = *getGlobalSTI();
   if ((AMDGPU::isGFX10Plus(STI) || AMDGPU::isGFX90A(STI)) &&
       (STI.getTargetTriple().getOS() == Triple::AMDHSA ||
-       STI.getTargetTriple().getOS() == Triple::AMDPAL)) {
+       STI.getTargetTriple().getOS() == Triple::AMDPAL) &&
+      !M.empty()) {
----------------
arsenm wrote:

Plus this may misdetect available_externally functions which will be dropped 

https://github.com/llvm/llvm-project/pull/147980


More information about the llvm-commits mailing list