Skip to content

Commit b95d50e

Browse files
tsymallaThomas Symalla
andauthored
Add and call AMDGPUMCResourceInfo::reset method (#110818)
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`. Different approach would be to make it a `unique_ptr`. --------- Co-authored-by: Thomas Symalla <[email protected]>
1 parent 7cc4aa4 commit b95d50e

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ bool AMDGPUAsmPrinter::doInitialization(Module &M) {
358358
report_fatal_error("Unexpected code object version");
359359
}
360360
}
361+
361362
return AsmPrinter::doInitialization(M);
362363
}
363364

@@ -511,6 +512,8 @@ bool AMDGPUAsmPrinter::doFinalization(Module &M) {
511512
for (Function &F : M.functions())
512513
validateMCResourceInfo(F);
513514

515+
RI.reset();
516+
514517
return AsmPrinter::doFinalization(M);
515518
}
516519

llvm/lib/Target/AMDGPU/AMDGPUMCResourceInfo.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ void MCResourceInfo::assignMaxRegs(MCContext &OutContext) {
7171
assignMaxRegSym(MaxSGPRSym, MaxSGPR);
7272
}
7373

74+
void MCResourceInfo::reset() { *this = MCResourceInfo(); }
75+
7476
void MCResourceInfo::finalize(MCContext &OutContext) {
7577
assert(!Finalized && "Cannot finalize ResourceInfo again.");
7678
Finalized = true;

llvm/lib/Target/AMDGPU/AMDGPUMCResourceInfo.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ class MCResourceInfo {
7575
const MCExpr *getSymRefExpr(StringRef FuncName, ResourceInfoKind RIK,
7676
MCContext &Ctx);
7777

78+
void reset();
79+
7880
// Resolves the final symbols that requires the inter-function resource info
7981
// to be resolved.
8082
void finalize(MCContext &OutContext);

0 commit comments

Comments
 (0)