Skip to content

Commit 821d52c

Browse files
author
Thomas Symalla
committed
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::doInitialization`.
1 parent 4f6ad17 commit 821d52c

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-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,9 @@ bool AMDGPUAsmPrinter::doInitialization(Module &M) {
358358
report_fatal_error("Unexpected code object version");
359359
}
360360
}
361+
362+
RI.reset();
363+
361364
return AsmPrinter::doInitialization(M);
362365
}
363366

llvm/lib/Target/AMDGPU/AMDGPUMCResourceInfo.cpp

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

74+
void MCResourceInfo::reset() {
75+
Finalized = false;
76+
MaxVGPR = 0;
77+
MaxAGPR = 0;
78+
MaxSGPR = 0;
79+
}
80+
7481
void MCResourceInfo::finalize(MCContext &OutContext) {
7582
assert(!Finalized && "Cannot finalize ResourceInfo again.");
7683
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)