Skip to content

Commit a4b6b9f

Browse files
committed
Fix bug in FixStackmapsSpillReloads pass.
This pass is responsible for moving stackmap calls at the machine IR level before register spill reloads inserted by the register allocator. Doing so requires the reloaded registers tracked by stackmaps to be replaced with the spill location on the stack. In rare cases it can happen that an implicit register in the stackmap (which is not written into the stackmap record) is being replaced with a spill location, which forces it to be written to the stackmap. This can lead to bugs during deoptimisation (e.g. the number of LLVM IR variables inside the stackmap call doesn't match the amount of locations in the stackmap record). Omitting implicit registers during this pass, fixes this problem.
1 parent 0cc0d20 commit a4b6b9f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

llvm/lib/CodeGen/Yk/FixStackmapsSpillReloads.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,11 @@ bool FixStackmapsSpillReloads::runOnMachineFunction(MachineFunction &MF) {
137137
Register Reg = MOI->getReg();
138138
// Check if the register operand in the stackmap is a restored
139139
// spill.
140-
if (Spills.count(Reg) > 0) {
140+
// Since implicit operands are ignored by stackmaps (they are not
141+
// added into the record) we must not replace them with spills so
142+
// we don't add extra locations that aren't needed. Doing so leads
143+
// to bugs during deoptimisation.
144+
if (Spills.count(Reg) > 0 && !MOI->isImplicit()) {
141145
// Get spill reload instruction
142146
MachineInstr *SMI = Spills[Reg];
143147
int FI;

0 commit comments

Comments
 (0)