Skip to content

Commit aab4ce4

Browse files
tonykuttaiTony Varghese
andauthored
[NFC][shrinkwrap] Add test point to capture the prologue and epilogue insertion by shrinkwrap pass for powerpc. (#131192)
This is NFC patch to capture the insertion of prologue and epilogue by `shrinkwrap` pass for Powerpc target for functions that contain llvm `__builtin_frame_address`. --------- Co-authored-by: Tony Varghese <[email protected]>
1 parent d85a81b commit aab4ce4

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
; Test file to verify the prologue and epilogue insertion point computation by the shrink-wrap pass
2+
3+
; RUN: llc -verify-machineinstrs < %s -mtriple=powerpc64le-unknown-unknown -mcpu=pwr9 | FileCheck %s --check-prefixes=POWERPC64
4+
; RUN: llc -verify-machineinstrs < %s -mtriple=powerpc-ibm-aix-xcoff -mcpu=pwr9 | FileCheck %s --check-prefixes=POWERPC32-AIX
5+
; RUN: llc -verify-machineinstrs < %s -mtriple=powerpc64-ibm-aix-xcoff -mcpu=pwr9 | FileCheck %s --check-prefixes=POWERPC64-AIX
6+
7+
define void @foo(ptr noundef readnone %parent_frame_pointer) {
8+
; POWERPC64-LABEL: foo
9+
; POWERPC64: # %bb.0:
10+
; POWERPC64-NEXT: cmpld [[REG1:[0-9]+]], 1
11+
; POWERPC64: # %bb.1:
12+
; POWERPC64-NEXT: mflr [[REG2:[0-9]+]]
13+
; POWERPC64-NEXT: stdu 1, -32(1)
14+
15+
; POWERPC32-AIX-LABEL: .foo:
16+
; POWERPC32-AIX: # %bb.0:
17+
; POWERPC32-AIX-NEXT: cmplw [[REG1:[0-9]+]], 1
18+
; POWERPC32-AIX: # %bb.1:
19+
; POWERPC32-AIX-NEXT: mflr [[REG2:[0-9]+]]
20+
; POWERPC32-AIX-NEXT: stwu 1, -64(1)
21+
22+
; POWERPC64-AIX-LABEL: .foo:
23+
; POWERPC64-AIX: # %bb.0:
24+
; POWERPC64-AIX-NEXT: cmpld [[REG1:[0-9]+]], 1
25+
; POWERPC64-AIX: # %bb.1:
26+
; POWERPC64-AIX-NEXT: mflr [[REG2:[0-9]+]]
27+
; POWERPC64-AIX-NEXT: stdu 1, -112(1)
28+
29+
entry:
30+
%frameaddress = tail call ptr @llvm.frameaddress.p0(i32 0)
31+
%cmp = icmp ugt ptr %parent_frame_pointer, %frameaddress
32+
br i1 %cmp, label %cond.end, label %cond.false
33+
34+
cond.false: ; preds = %entry
35+
tail call void @abort()
36+
unreachable
37+
38+
cond.end: ; preds = %entry
39+
ret void
40+
}
41+
42+
declare ptr @llvm.frameaddress.p0(i32 immarg)
43+
declare void @abort()
44+
45+
define noundef i32 @main() {
46+
; POWERPC64-LABEL: main
47+
; POWERPC64: # %bb.0:
48+
; POWERPC64-NEXT: mflr [[REG1:[0-9]+]]
49+
; POWERPC64-NEXT: stdu 1, -32(1)
50+
; POWERPC64-NEXT: std [[REG1]], 48(1)
51+
; POWERPC64: mr [[REG2:[0-9]+]], 1
52+
; POWERPC64: addi 1, 1, 32
53+
; POWERPC64-NEXT: ld [[REG1]], 16(1)
54+
; POWERPC64-NEXT: mtlr [[REG1]]
55+
; POWERPC64-NEXT: blr
56+
57+
; POWERPC32-AIX-LABEL: .main:
58+
; POWERPC32-AIX: # %bb.0:
59+
; POWERPC32-AIX-NEXT: mflr [[REG1:[0-9]+]]
60+
; POWERPC32-AIX-NEXT: stwu 1, -64(1)
61+
; POWERPC32-AIX-NEXT: mr [[REG2:[0-9]+]], 1
62+
; POWERPC32-AIX-NEXT: stw [[REG1]], 72(1)
63+
; POWERPC32-AIX: addi 1, 1, 64
64+
; POWERPC32-AIX-NEXT: lwz [[REG1]], 8(1)
65+
; POWERPC32-AIX-NEXT: mtlr [[REG1]]
66+
; POWERPC32-AIX-NEXT: blr
67+
68+
; POWERPC64-AIX-LABEL: .main:
69+
; POWERPC64-AIX: # %bb.0:
70+
; POWERPC64-AIX-NEXT: mflr [[REG1:[0-9]+]]
71+
; POWERPC64-AIX-NEXT: stdu 1, -112(1)
72+
; POWERPC64-AIX-NEXT: mr [[REG2:[0-9]+]], 1
73+
; POWERPC64-AIX-NEXT: std [[REG1]], 128(1)
74+
; POWERPC64-AIX: addi 1, 1, 112
75+
; POWERPC64-AIX-NEXT: ld [[REG1]], 16(1)
76+
; POWERPC64-AIX-NEXT: mtlr [[REG1]]
77+
; POWERPC64-AIX-NEXT: blr
78+
79+
entry:
80+
%frameaddress = tail call ptr @llvm.frameaddress.p0(i32 0)
81+
tail call void @foo(ptr noundef %frameaddress)
82+
ret i32 0
83+
}

0 commit comments

Comments
 (0)