llvm.org GIT mirror llvm / c1c411e
[X86] Don't clobber reserved registers with stack adjustments Summary: Calls using invoke in funclet based functions are assumed to clobber all registers, which causes the stack adjustment using pops to consider all registers not defined by the call to be undefined, which can unfortunately include the base pointer, if one is needed. To prevent this (and possibly other hazards), skip reserved registers when looking for candidate registers. This fixes issue #45034 in the Rust compiler. Reviewers: mkuper Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D39636 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317551 91177308-0d34-0410-b5e6-96231b3b80d8 Bjorn Steinbrink 1 year, 11 months ago
2 changed file(s) with 31 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
25762576 unsigned Regs[2];
25772577 unsigned FoundRegs = 0;
25782578
2579 auto &MRI = MBB.getParent()->getRegInfo();
25792580 auto RegMask = Prev->getOperand(1);
25802581
25812582 auto &RegClass =
25872588 // Since we're immediately after a call, any register that is clobbered
25882589 // by the call and not defined by it can be considered dead.
25892590 if (!RegMask.clobbersPhysReg(Candidate))
2591 continue;
2592
2593 // Don't clobber reserved registers
2594 if (MRI.isReserved(Candidate))
25902595 continue;
25912596
25922597 bool IsDef = false;
0 ; RUN: llc < %s | FileCheck %s
1
2 target triple = "i686--windows-msvc"
3
4 declare { i8*, i32 } @param2_ret2(i32, i32)
5 declare i32 @__CxxFrameHandler3(...)
6
7
8 define void @test_reserved_regs() minsize optsize personality i32 (...)* @__CxxFrameHandler3 {
9 ; CHECK-LABEL: test_reserved_regs:
10 ; CHECK: calll _param2_ret2
11 ; CHECK-NEXT: popl %ecx
12 ; CHECK-NEXT: popl %edi
13 start:
14 %s = alloca i64
15 store i64 4, i64* %s
16 %0 = invoke { i8*, i32 } @param2_ret2(i32 0, i32 1)
17 to label %out unwind label %cleanup
18
19 out:
20 ret void
21
22 cleanup:
23 %cp = cleanuppad within none []
24 cleanupret from %cp unwind to caller
25 }