Skip to content

Commit b8f9ec6

Browse files
precommit test for pr60855
This test demonstrates an issue with callbr outputs being used along indirect edges when using regallocfast. Link: #60855 Differential Revision: https://reviews.llvm.org/D144906
1 parent a7f8b7c commit b8f9ec6

File tree

1 file changed

+171
-0
lines changed

1 file changed

+171
-0
lines changed
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2+
# RUN: llc -run-pass=regallocfast -verify-machineinstrs %s -o - | FileCheck %s
3+
--- |
4+
; ModuleID = 'x.c'
5+
source_filename = "x.c"
6+
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
7+
target triple = "x86_64-unknown-linux-gnu"
8+
9+
; Function Attrs: noinline nounwind optnone
10+
define dso_local i32 @main() #0 {
11+
entry:
12+
%retval = alloca i32, align 4
13+
%x = alloca i32, align 4
14+
store i32 0, ptr %retval, align 4
15+
store i32 123, ptr %x, align 4
16+
%0 = callbr i32 asm "mov $1, $0\0A\09jmp ${2:l}", "=r,r,!i,~{dirflag},~{fpsr},~{flags}"(i32 45) #2
17+
to label %asm.fallthrough [label %label.split], !srcloc !5
18+
19+
asm.fallthrough: ; preds = %entry
20+
store i32 %0, ptr %x, align 4
21+
store i32 6, ptr %x, align 4
22+
br label %label
23+
24+
label: ; preds = %asm.fallthrough, %label.split
25+
%1 = load i32, ptr %x, align 4
26+
ret i32 %1
27+
28+
label.split: ; preds = %entry
29+
%2 = call i32 @llvm.callbr.landingpad.i32(i32 %0)
30+
store i32 %2, ptr %x, align 4
31+
br label %label
32+
}
33+
34+
; Function Attrs: nomerge nounwind
35+
declare i32 @llvm.callbr.landingpad.i32(i32) #1
36+
37+
attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
38+
attributes #1 = { nomerge nounwind }
39+
attributes #2 = { nounwind memory(none) }
40+
41+
!llvm.module.flags = !{!0, !1, !2, !3}
42+
!llvm.ident = !{!4}
43+
44+
!0 = !{i32 1, !"wchar_size", i32 4}
45+
!1 = !{i32 8, !"PIC Level", i32 2}
46+
!2 = !{i32 7, !"PIE Level", i32 2}
47+
!3 = !{i32 7, !"frame-pointer", i32 2}
48+
!4 = !{!"clang version 17.0.0 ([email protected]:llvm/llvm-project.git cf86855c4453d029a9b9ed8c4c4c18cefc1bc895)"}
49+
!5 = !{i64 166, i64 179}
50+
51+
...
52+
---
53+
name: main
54+
alignment: 16
55+
exposesReturnsTwice: false
56+
legalized: false
57+
regBankSelected: false
58+
selected: false
59+
failedISel: false
60+
tracksRegLiveness: true
61+
hasWinCFI: false
62+
callsEHReturn: false
63+
callsUnwindInit: false
64+
hasEHCatchret: false
65+
hasEHScopes: false
66+
hasEHFunclets: false
67+
debugInstrRef: false
68+
failsVerification: false
69+
tracksDebugUserValues: false
70+
registers:
71+
- { id: 0, class: gr32, preferred-register: '' }
72+
- { id: 1, class: gr32, preferred-register: '' }
73+
- { id: 2, class: gr32, preferred-register: '' }
74+
- { id: 3, class: gr32, preferred-register: '' }
75+
- { id: 4, class: gr32, preferred-register: '' }
76+
- { id: 5, class: gr32, preferred-register: '' }
77+
- { id: 6, class: gr32, preferred-register: '' }
78+
liveins: []
79+
frameInfo:
80+
isFrameAddressTaken: false
81+
isReturnAddressTaken: false
82+
hasStackMap: false
83+
hasPatchPoint: false
84+
stackSize: 0
85+
offsetAdjustment: 0
86+
maxAlignment: 4
87+
adjustsStack: false
88+
hasCalls: false
89+
stackProtector: ''
90+
functionContext: ''
91+
maxCallFrameSize: 4294967295
92+
cvBytesOfCalleeSavedRegisters: 0
93+
hasOpaqueSPAdjustment: false
94+
hasVAStart: false
95+
hasMustTailInVarArgFunc: false
96+
hasTailCall: false
97+
localFrameSize: 0
98+
savePoint: ''
99+
restorePoint: ''
100+
fixedStack: []
101+
stack:
102+
- { id: 0, name: retval, type: default, offset: 0, size: 4, alignment: 4,
103+
stack-id: default, callee-saved-register: '', callee-saved-restored: true,
104+
debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
105+
- { id: 1, name: x, type: default, offset: 0, size: 4, alignment: 4,
106+
stack-id: default, callee-saved-register: '', callee-saved-restored: true,
107+
debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
108+
callSites: []
109+
debugValueSubstitutions: []
110+
constants: []
111+
machineFunctionInfo: {}
112+
body: |
113+
; CHECK-LABEL: name: main
114+
; CHECK: bb.0.entry:
115+
; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.3(0x40000000)
116+
; CHECK-NEXT: {{ $}}
117+
; CHECK-NEXT: MOV32mi %stack.0.retval, 1, $noreg, 0, $noreg, 0 :: (store (s32) into %ir.retval)
118+
; CHECK-NEXT: MOV32mi %stack.1.x, 1, $noreg, 0, $noreg, 123 :: (store (s32) into %ir.x)
119+
; CHECK-NEXT: renamable $eax = MOV32ri 45
120+
; CHECK-NEXT: INLINEASM_BR &"mov $1, $0\0A\09jmp ${2:l}", 0 /* attdialect */, 2359306 /* regdef:GR32 */, def renamable $eax, 2359305 /* reguse:GR32 */, killed renamable $eax, 13 /* imm */, %bb.3, 12 /* clobber */, implicit-def dead early-clobber $df, 12 /* clobber */, implicit-def early-clobber $fpsw, 12 /* clobber */, implicit-def dead early-clobber $eflags, !5
121+
; CHECK-NEXT: MOV32mr %stack.3, 1, $noreg, 0, $noreg, $eax :: (store (s32) into %stack.3)
122+
; CHECK-NEXT: MOV32mr %stack.2, 1, $noreg, 0, $noreg, killed $eax :: (store (s32) into %stack.2)
123+
; CHECK-NEXT: JMP_1 %bb.1
124+
; CHECK-NEXT: {{ $}}
125+
; CHECK-NEXT: bb.1.asm.fallthrough:
126+
; CHECK-NEXT: successors: %bb.2(0x80000000)
127+
; CHECK-NEXT: {{ $}}
128+
; CHECK-NEXT: $eax = MOV32rm %stack.2, 1, $noreg, 0, $noreg :: (load (s32) from %stack.2)
129+
; CHECK-NEXT: MOV32mr %stack.1.x, 1, $noreg, 0, $noreg, renamable $eax :: (store (s32) into %ir.x)
130+
; CHECK-NEXT: MOV32mi %stack.1.x, 1, $noreg, 0, $noreg, 6 :: (store (s32) into %ir.x)
131+
; CHECK-NEXT: {{ $}}
132+
; CHECK-NEXT: bb.2.label:
133+
; CHECK-NEXT: renamable $eax = MOV32rm %stack.1.x, 1, $noreg, 0, $noreg :: (load (s32) from %ir.x)
134+
; CHECK-NEXT: RET64 implicit killed $eax
135+
; CHECK-NEXT: {{ $}}
136+
; CHECK-NEXT: bb.3.label.split (machine-block-address-taken, inlineasm-br-indirect-target):
137+
; CHECK-NEXT: successors: %bb.2(0x80000000)
138+
; CHECK-NEXT: {{ $}}
139+
; FIXME: this is a load from a stack slot that hasn't been stored to yet!
140+
; CHECK-NEXT: $eax = MOV32rm %stack.3, 1, $noreg, 0, $noreg :: (load (s32) from %stack.3)
141+
; CHECK-NEXT: MOV32mr %stack.1.x, 1, $noreg, 0, $noreg, killed renamable $eax :: (store (s32) into %ir.x)
142+
; CHECK-NEXT: JMP_1 %bb.2
143+
bb.0.entry:
144+
successors: %bb.1(0x40000000), %bb.3(0x40000000)
145+
146+
MOV32mi %stack.0.retval, 1, $noreg, 0, $noreg, 0 :: (store (s32) into %ir.retval)
147+
MOV32mi %stack.1.x, 1, $noreg, 0, $noreg, 123 :: (store (s32) into %ir.x)
148+
%2:gr32 = MOV32ri 45
149+
INLINEASM_BR &"mov $1, $0\0A\09jmp ${2:l}", 0 /* attdialect */, 2359306 /* regdef:GR32 */, def %1, 2359305 /* reguse:GR32 */, %2, 13 /* imm */, %bb.3, 12 /* clobber */, implicit-def early-clobber $df, 12 /* clobber */, implicit-def early-clobber $fpsw, 12 /* clobber */, implicit-def early-clobber $eflags, !5
150+
%0:gr32 = COPY %1
151+
JMP_1 %bb.1
152+
153+
bb.1.asm.fallthrough:
154+
successors: %bb.2(0x80000000)
155+
156+
MOV32mr %stack.1.x, 1, $noreg, 0, $noreg, %0 :: (store (s32) into %ir.x)
157+
MOV32mi %stack.1.x, 1, $noreg, 0, $noreg, 6 :: (store (s32) into %ir.x)
158+
159+
bb.2.label:
160+
%6:gr32 = MOV32rm %stack.1.x, 1, $noreg, 0, $noreg :: (load (s32) from %ir.x)
161+
$eax = COPY %6
162+
RET64 implicit $eax
163+
164+
bb.3.label.split (machine-block-address-taken, inlineasm-br-indirect-target):
165+
successors: %bb.2(0x80000000)
166+
167+
%3:gr32 = COPY %1
168+
MOV32mr %stack.1.x, 1, $noreg, 0, $noreg, %3 :: (store (s32) into %ir.x)
169+
JMP_1 %bb.2
170+
171+
...

0 commit comments

Comments
 (0)