Skip to content

Commit cde4457

Browse files
authored
[ShrinkWrap][NFC] Test with load from constant pool preventing shrink (llvm#162476)
wrapping Shrink wrapping treats a load from constant pool as a stack access. This is not correct. Constants are basically stored in read only section AFAIU. This prevents shrink wrapping from kicking in. (Related to PR llvm#160257. PR llvm#160257 will be closed.)
1 parent 12bf183 commit cde4457

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# RUN: llc -mtriple=aarch64 -simplify-mir -run-pass=shrink-wrap -o - %s | FileCheck %s
2+
--- |
3+
declare double @foo()
4+
5+
define double @shrink_wrap_load_from_const_pool(double %q) {
6+
entry:
7+
%0 = fcmp oeq double %q, 3.125500e+02
8+
br i1 %0, label %common.ret, label %if.else
9+
10+
common.ret: ; preds = %if.else, %entry, %exit1
11+
%common.ret.op = phi double [ %3, %exit1 ], [ 0.000000e+00, %entry ], [ 0.000000e+00, %if.else ]
12+
ret double %common.ret.op
13+
14+
if.else: ; preds = %entry
15+
%1 = call double @foo()
16+
%2 = fcmp oeq double %1, 0.000000e+00
17+
br i1 %2, label %exit1, label %common.ret
18+
19+
exit1: ; preds = %if.else
20+
%3 = call double @foo()
21+
br label %common.ret
22+
}
23+
...
24+
# FIXME: Following code has a load from constant pool. Accessing constant pool
25+
# must not be considered as a stack access and hence, shrink wrapping must
26+
# happen.
27+
# CHECK-LABEL:name: shrink_wrap_load_from_const_pool
28+
# CHECK-NOT: savePoint
29+
# CHECK-NOT: restorePoint
30+
---
31+
name: shrink_wrap_load_from_const_pool
32+
tracksRegLiveness: true
33+
constants:
34+
- id: 0
35+
value: 'double 3.125500e+02'
36+
alignment: 8
37+
body: |
38+
bb.0.entry:
39+
successors: %bb.4(0x50000000), %bb.2(0x30000000)
40+
liveins: $d0
41+
42+
renamable $d1 = COPY $d0
43+
renamable $x8 = ADRP target-flags(aarch64-page) %const.0
44+
renamable $d2 = LDRDui killed renamable $x8, target-flags(aarch64-pageoff, aarch64-nc) %const.0 :: (load (s64) from constant-pool)
45+
renamable $d0 = FMOVD0
46+
nofpexcept FCMPDrr killed renamable $d1, killed renamable $d2, implicit-def $nzcv, implicit $fpcr
47+
Bcc 1, %bb.2, implicit killed $nzcv
48+
49+
bb.4:
50+
liveins: $d0
51+
52+
bb.1.common.ret:
53+
liveins: $d0
54+
55+
RET_ReallyLR implicit $d0
56+
57+
bb.2.if.else:
58+
successors: %bb.3(0x50000000), %bb.1(0x30000000)
59+
60+
ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp
61+
BL @foo, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp, implicit-def $d0
62+
ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp
63+
renamable $d1 = COPY $d0
64+
renamable $d0 = FMOVD0
65+
nofpexcept FCMPDri killed renamable $d1, implicit-def $nzcv, implicit $fpcr
66+
Bcc 1, %bb.1, implicit killed $nzcv
67+
B %bb.3
68+
69+
bb.3.exit1:
70+
ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp
71+
BL @foo, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp, implicit-def $d0
72+
ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp
73+
B %bb.1
74+
...

0 commit comments

Comments
 (0)