[llvm] Add and call `AMDGPUMCResourceInfo::reset` method (PR #110818)
Thomas Symalla via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 2 03:58:07 PDT 2024
https://github.com/tsymalla updated https://github.com/llvm/llvm-project/pull/110818
>From ea4563710b24d6497b2dd655f81e8c62019fc5d7 Mon Sep 17 00:00:00 2001
From: Thomas Symalla <tsymalla at amd.com>
Date: Wed, 2 Oct 2024 12:27:41 +0200
Subject: [PATCH 1/2] Add and call `AMDGPUMCResourceInfo::reset` method
When compiling multiple pipelines, the `MCRegisterInfo` instance in
`AMDGPUAsmPrinter` gets re-used even after finalization, so it calls
`finalize()` multiple times.
Add a reset method and call it in
`AMDGPUAsmPrinter::doFinalization`.
---
llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp | 3 +++
llvm/lib/Target/AMDGPU/AMDGPUMCResourceInfo.cpp | 2 ++
llvm/lib/Target/AMDGPU/AMDGPUMCResourceInfo.h | 2 ++
3 files changed, 7 insertions(+)
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
index 4f6633d8027c70..974f1c80d95530 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
@@ -358,6 +358,7 @@ bool AMDGPUAsmPrinter::doInitialization(Module &M) {
report_fatal_error("Unexpected code object version");
}
}
+
return AsmPrinter::doInitialization(M);
}
@@ -511,6 +512,8 @@ bool AMDGPUAsmPrinter::doFinalization(Module &M) {
for (Function &F : M.functions())
validateMCResourceInfo(F);
+ RI.reset();
+
return AsmPrinter::doFinalization(M);
}
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUMCResourceInfo.cpp b/llvm/lib/Target/AMDGPU/AMDGPUMCResourceInfo.cpp
index f608a9a4f470fa..1de6bf1631a25b 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUMCResourceInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUMCResourceInfo.cpp
@@ -71,6 +71,8 @@ void MCResourceInfo::assignMaxRegs(MCContext &OutContext) {
assignMaxRegSym(MaxSGPRSym, MaxSGPR);
}
+void MCResourceInfo::reset() { *this = MCResourceInfo(); }
+
void MCResourceInfo::finalize(MCContext &OutContext) {
assert(!Finalized && "Cannot finalize ResourceInfo again.");
Finalized = true;
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUMCResourceInfo.h b/llvm/lib/Target/AMDGPU/AMDGPUMCResourceInfo.h
index 08c0c106d5aa9b..9f7f4b1b8f75ff 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUMCResourceInfo.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUMCResourceInfo.h
@@ -75,6 +75,8 @@ class MCResourceInfo {
const MCExpr *getSymRefExpr(StringRef FuncName, ResourceInfoKind RIK,
MCContext &Ctx);
+ void reset();
+
// Resolves the final symbols that requires the inter-function resource info
// to be resolved.
void finalize(MCContext &OutContext);
>From 53b05312059f767ffe1153a6c8b127060bd4fbf1 Mon Sep 17 00:00:00 2001
From: Thomas Symalla <tsymalla at amd.com>
Date: Wed, 2 Oct 2024 12:57:51 +0200
Subject: [PATCH 2/2] Clang-format
---
llvm/lib/Target/AMDGPU/AMDGPUMCResourceInfo.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUMCResourceInfo.h b/llvm/lib/Target/AMDGPU/AMDGPUMCResourceInfo.h
index 9f7f4b1b8f75ff..9dc34100e644e6 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUMCResourceInfo.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUMCResourceInfo.h
@@ -76,7 +76,7 @@ class MCResourceInfo {
MCContext &Ctx);
void reset();
-
+
// Resolves the final symbols that requires the inter-function resource info
// to be resolved.
void finalize(MCContext &OutContext);
More information about the llvm-commits
mailing list