Skip to content

Commit 4cf34d7

Browse files
committed
[PowerPC] provide CFI for ELF32 to unwind cr2, cr3, cr4
Delete the code that skips the CFI for the condition register on ELF32. The code checked !MustSaveCR, which happened only when Subtarget.is32BitELFABI(), where spillCalleeSavedRegisters is spilling cr in a different way. The spill was missing CFI. After deleting this code, a spill of cr2 to cr4 gets CFI in the same way as a spill of r14 to r31. Fixes #83094
1 parent 3851558 commit 4cf34d7

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

llvm/lib/Target/PowerPC/PPCFrameLowering.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,12 +1191,6 @@ void PPCFrameLowering::emitPrologue(MachineFunction &MF,
11911191
if ((Reg == PPC::X2 || Reg == PPC::R2) && MustSaveTOC)
11921192
continue;
11931193

1194-
// For SVR4, don't emit a move for the CR spill slot if we haven't
1195-
// spilled CRs.
1196-
if (isSVR4ABI && (PPC::CR2 <= Reg && Reg <= PPC::CR4)
1197-
&& !MustSaveCR)
1198-
continue;
1199-
12001194
// For 64-bit SVR4 when we have spilled CRs, the spill location
12011195
// is SP+8, not a frame-relative slot.
12021196
if (isSVR4ABI && isPPC64 && (PPC::CR2 <= Reg && Reg <= PPC::CR4)) {

llvm/test/CodeGen/PowerPC/crsave.ll

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ entry:
1515
}
1616

1717
; PPC32-LABEL: test_cr2:
18-
; PPC32: stwu 1, -32(1)
19-
; PPC32: stw 31, 28(1)
18+
; PPC32: stwu 1, -[[#%u,AMT:]](1)
19+
; PPC32: stw 31, [[#AMT - 4]](1)
20+
; PPC32: .cfi_offset cr2, -[[#%u,DOWN:]]
2021
; PPC32: mfcr 12
21-
; PPC32-NEXT: stw 12, 24(31)
22-
; PPC32: lwz 12, 24(31)
22+
; PPC32-NEXT: stw 12, [[#AMT - DOWN]](31)
23+
; PPC32: lwz 12, [[#AMT - DOWN]](31)
2324
; PPC32-NEXT: mtocrf 32, 12
2425

2526
; PPC64: .cfi_startproc
@@ -34,7 +35,7 @@ entry:
3435
; PPC64: mtocrf 32, 12
3536
; PPC64: .cfi_endproc
3637

37-
define i32 @test_cr234() nounwind {
38+
define i32 @test_cr234() nounwind uwtable {
3839
entry:
3940
%ret = alloca i32, align 4
4041
%0 = call i32 asm sideeffect "\0A\09mtcr $4\0A\09cmpw 2,$2,$1\0A\09cmpw 3,$2,$2\0A\09cmpw 4,$2,$3\0A\09mfcr $0", "=r,r,r,r,r,~{cr2},~{cr3},~{cr4}"(i32 1, i32 2, i32 3, i32 0) nounwind
@@ -45,11 +46,14 @@ entry:
4546
}
4647

4748
; PPC32-LABEL: test_cr234:
48-
; PPC32: stwu 1, -32(1)
49-
; PPC32: stw 31, 28(1)
49+
; PPC32: stwu 1, -[[#%u,AMT:]](1)
50+
; PPC32: stw 31, [[#AMT - 4]](1)
51+
; PPC32: .cfi_offset cr2, -[[#%u,DOWN:]]
52+
; PPC32: .cfi_offset cr3, -[[#DOWN]]
53+
; PPC32: .cfi_offset cr4, -[[#DOWN]]
5054
; PPC32: mfcr 12
51-
; PPC32-NEXT: stw 12, 24(31)
52-
; PPC32: lwz 12, 24(31)
55+
; PPC32-NEXT: stw 12, [[#AMT - DOWN]](31)
56+
; PPC32: lwz 12, [[#AMT - DOWN]](31)
5357
; PPC32-NEXT: mtocrf 32, 12
5458
; PPC32-NEXT: mtocrf 16, 12
5559
; PPC32-NEXT: mtocrf 8, 12

0 commit comments

Comments
 (0)