Skip to content

Commit

Permalink
Add and call AMDGPUMCResourceInfo::reset method
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
Thomas Symalla committed Oct 2, 2024
1 parent 4f6ad17 commit 821d52c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,9 @@ bool AMDGPUAsmPrinter::doInitialization(Module &M) {
report_fatal_error("Unexpected code object version");
}
}

RI.reset();

return AsmPrinter::doInitialization(M);
}

Expand Down
7 changes: 7 additions & 0 deletions llvm/lib/Target/AMDGPU/AMDGPUMCResourceInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ void MCResourceInfo::assignMaxRegs(MCContext &OutContext) {
assignMaxRegSym(MaxSGPRSym, MaxSGPR);
}

void MCResourceInfo::reset() {
Finalized = false;
MaxVGPR = 0;
MaxAGPR = 0;
MaxSGPR = 0;
}

void MCResourceInfo::finalize(MCContext &OutContext) {
assert(!Finalized && "Cannot finalize ResourceInfo again.");
Finalized = true;
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/AMDGPU/AMDGPUMCResourceInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 821d52c

Please sign in to comment.