[llvm] AMDGPU: Don't pad .text with s_code_end if it would otherwise be empty (PR #147980)
Tim Renouf via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 10 07:55:55 PDT 2025
https://github.com/trenouf created https://github.com/llvm/llvm-project/pull/147980
We don't want that padding in a module that only contains data, not code.
>From 9f4e8e170bb2978fd5bbb6dbac0900c51ea09af7 Mon Sep 17 00:00:00 2001
From: Tim Renouf <tim.renouf at amd.com>
Date: Thu, 20 Feb 2025 09:47:55 +0000
Subject: [PATCH] AMDGPU: Don't pad .text with s_code_end if it would otherwise
be empty
We don't want that padding in a module that only contains data, not
code.
---
llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
index 749b9efc81378..3765c1d2b106c 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
@@ -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()) {
OutStreamer->switchSection(getObjFileLowering().getTextSection());
getTargetStreamer()->EmitCodeEnd(STI);
}
More information about the llvm-commits
mailing list