Skip to content

Commit 5bd22b7

Browse files
committed
Add new TDN codegen tests with dead regions
These tests previously caused scheduler failures because it visited nodes in CFG-dead regions. While a scheduler test would have been most appropriate here, I couldn't set it up easily because filecheck doesn't allow matches against variables defined in the same pattern.
1 parent 938c1ea commit 5bd22b7

File tree

2 files changed

+761
-0
lines changed

2 files changed

+761
-0
lines changed
Lines changed: 357 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,357 @@
1+
# run: codegen
2+
3+
extfunc @jit_throw(ptr)
4+
extfunc @jit_throw_index_out_of_range()
5+
extfunc @jit_throw_invalid_cast()
6+
extfunc @"System.Void System.String::CopyStringContent(System.String, System.Int32, System.String)"(ptr, i32, ptr)
7+
extfunc @"System.String System.String::FastAllocateString(System.Int32)":ptr(i32)
8+
extfunc @jit_newobj:ptr(ptr)
9+
10+
func @"System.String System.String::Concat(System.String[])":ptr(ptr) {
11+
# check: function `System.String System.String::Concat(System.String[])`:
12+
# nextln: 000000: 55 push rbp
13+
# nextln: 000001: 48 89 e5 mov rbp, rsp
14+
# nextln: 000004: 41 57 push r15
15+
# nextln: 000006: 41 56 push r14
16+
# nextln: 000008: 41 55 push r13
17+
# nextln: 00000a: 41 54 push r12
18+
# nextln: 00000c: 53 push rbx
19+
# nextln: 00000d: 48 83 ec 18 sub rsp, 0x18
20+
# nextln: 000011: 33 c0 xor eax, eax
21+
# nextln: 000013: 48 85 ff test rdi, rdi
22+
# nextln: 000016: 0f 94 c0 sete al
23+
# nextln: 000019: 0f b6 c0 movzx eax, al
24+
# nextln: 00001c: 85 c0 test eax, eax
25+
# nextln: 00001e: 0f 84 35 00 00 00 je 0x59
26+
# nextln: 000024: 48 bf c0 73 5e 81 c7 7c 00 00 movabs rdi, 0x7cc7815e73c0
27+
# nextln: 00002e: 48 b8 00 00 00 00 00 00 00 00 movabs rax, 0 # RELOC_ABS64 -> @jit_newobj + 0
28+
# nextln: 000038: ff d0 call rax
29+
# nextln: 00003a: 48 b9 10 4c 54 83 e7 7b 00 00 movabs rcx, 0x7be783544c10
30+
# nextln: 000044: 48 89 48 10 mov qword ptr [rax + 0x10], rcx
31+
# nextln: 000048: 48 b9 00 00 00 00 00 00 00 00 movabs rcx, 0 # RELOC_ABS64 -> @jit_throw + 0
32+
# nextln: 000052: 48 89 c7 mov rdi, rax
33+
# nextln: 000055: ff d1 call rcx
34+
# nextln: 000057: 0f 0b ud2
35+
# nextln: 000059: 8b 4f 10 mov ecx, dword ptr [rdi + 0x10]
36+
# nextln: 00005c: 33 c0 xor eax, eax
37+
# nextln: 00005e: 83 f9 01 cmp ecx, 1
38+
# nextln: 000061: 0f 9f c0 setg al
39+
# nextln: 000064: 33 c9 xor ecx, ecx
40+
# nextln: 000066: 85 c0 test eax, eax
41+
# nextln: 000068: 0f 94 c1 sete cl
42+
# nextln: 00006b: 0f b6 c9 movzx ecx, cl
43+
# nextln: 00006e: 48 b8 b0 1b 5e 81 c7 7b 00 00 movabs rax, 0x7bc7815e1bb0
44+
# nextln: 000078: 45 33 ed xor r13d, r13d
45+
# nextln: 00007b: 85 c9 test ecx, ecx
46+
# nextln: 00007d: 0f 84 43 00 00 00 je 0xc6
47+
# nextln: 000083: 8b 4f 10 mov ecx, dword ptr [rdi + 0x10]
48+
# nextln: 000086: 48 85 c9 test rcx, rcx
49+
# nextln: 000089: 0f 84 2f 00 00 00 je 0xbe
50+
# nextln: 00008f: 8b 4f 10 mov ecx, dword ptr [rdi + 0x10]
51+
# nextln: 000092: 48 85 c9 test rcx, rcx
52+
# nextln: 000095: 0f 84 15 00 00 00 je 0xb0
53+
# nextln: 00009b: 4c 8b 77 18 mov r14, qword ptr [rdi + 0x18]
54+
# nextln: 00009f: 4d 85 f6 test r14, r14
55+
# nextln: 0000a2: 0f 85 d0 01 00 00 jne 0x278
56+
# nextln: 0000a8: 4c 8b 30 mov r14, qword ptr [rax]
57+
# nextln: 0000ab: e9 c8 01 00 00 jmp 0x278
58+
# nextln: 0000b0: 48 b8 00 00 00 00 00 00 00 00 movabs rax, 0 # RELOC_ABS64 -> @jit_throw_index_out_of_range + 0
59+
# nextln: 0000ba: ff d0 call rax
60+
# nextln: 0000bc: 0f 0b ud2
61+
# nextln: 0000be: 4c 8b 30 mov r14, qword ptr [rax]
62+
# nextln: 0000c1: e9 b2 01 00 00 jmp 0x278
63+
# nextln: 0000c6: 33 c9 xor ecx, ecx
64+
# nextln: 0000c8: 8b 77 10 mov esi, dword ptr [rdi + 0x10]
65+
# nextln: 0000cb: 33 d2 xor edx, edx
66+
# nextln: 0000cd: 3b ce cmp ecx, esi
67+
# nextln: 0000cf: 0f 9c c2 setl dl
68+
# nextln: 0000d2: 0f b6 d2 movzx edx, dl
69+
# nextln: 0000d5: 85 d2 test edx, edx
70+
# nextln: 0000d7: 0f 84 54 00 00 00 je 0x131
71+
# nextln: 0000dd: 8b 77 10 mov esi, dword ptr [rdi + 0x10]
72+
# nextln: 0000e0: 48 63 d1 movsxd rdx, ecx
73+
# nextln: 0000e3: 48 3b d6 cmp rdx, rsi
74+
# nextln: 0000e6: 0f 83 37 00 00 00 jae 0x123
75+
# nextln: 0000ec: 48 c1 e2 03 shl rdx, 3
76+
# nextln: 0000f0: 48 83 c2 18 add rdx, 0x18
77+
# nextln: 0000f4: 48 89 fe mov rsi, rdi
78+
# nextln: 0000f7: 48 03 f2 add rsi, rdx
79+
# nextln: 0000fa: 48 8b 16 mov rdx, qword ptr [rsi]
80+
# nextln: 0000fd: 33 f6 xor esi, esi
81+
# nextln: 0000ff: 48 85 d2 test rdx, rdx
82+
# nextln: 000102: 40 0f 95 c6 setne sil
83+
# nextln: 000106: 40 0f b6 f6 movzx esi, sil
84+
# nextln: 00010a: 85 f6 test esi, esi
85+
# nextln: 00010c: 0f 84 09 00 00 00 je 0x11b
86+
# nextln: 000112: 8b 52 10 mov edx, dword ptr [rdx + 0x10]
87+
# nextln: 000115: 48 63 d2 movsxd rdx, edx
88+
# nextln: 000118: 4c 03 ea add r13, rdx
89+
# nextln: 00011b: 83 c1 01 add ecx, 1
90+
# nextln: 00011e: e9 a5 ff ff ff jmp 0xc8
91+
# nextln: 000123: 48 b8 00 00 00 00 00 00 00 00 movabs rax, 0 # RELOC_ABS64 -> @jit_throw_index_out_of_range + 0
92+
# nextln: 00012d: ff d0 call rax
93+
# nextln: 00012f: 0f 0b ud2
94+
# nextln: 000131: 33 db xor ebx, ebx
95+
# nextln: 000133: 49 89 fc mov r12, rdi
96+
# nextln: 000136: 33 c9 xor ecx, ecx
97+
# nextln: 000138: 49 81 fd ff ff ff 7f cmp r13, 0x7fffffff
98+
# nextln: 00013f: 0f 9f c1 setg cl
99+
# nextln: 000142: 0f b6 c9 movzx ecx, cl
100+
# nextln: 000145: 85 c9 test ecx, ecx
101+
# nextln: 000147: 0f 84 27 00 00 00 je 0x174
102+
# nextln: 00014d: 48 bf 40 c3 5e 81 c7 7c 00 00 movabs rdi, 0x7cc7815ec340
103+
# nextln: 000157: 48 b8 00 00 00 00 00 00 00 00 movabs rax, 0 # RELOC_ABS64 -> @jit_newobj + 0
104+
# nextln: 000161: ff d0 call rax
105+
# nextln: 000163: 48 b9 00 00 00 00 00 00 00 00 movabs rcx, 0 # RELOC_ABS64 -> @jit_throw + 0
106+
# nextln: 00016d: 48 89 c7 mov rdi, rax
107+
# nextln: 000170: ff d1 call rcx
108+
# nextln: 000172: 0f 0b ud2
109+
# nextln: 000174: 33 c9 xor ecx, ecx
110+
# nextln: 000176: 45 85 ed test r13d, r13d
111+
# nextln: 000179: 0f 94 c1 sete cl
112+
# nextln: 00017c: 0f b6 c9 movzx ecx, cl
113+
# nextln: 00017f: 85 c9 test ecx, ecx
114+
# nextln: 000181: 0f 84 08 00 00 00 je 0x18f
115+
# nextln: 000187: 4c 8b 30 mov r14, qword ptr [rax]
116+
# nextln: 00018a: e9 e9 00 00 00 jmp 0x278
117+
# nextln: 00018f: 48 b8 00 00 00 00 00 00 00 00 movabs rax, 0 # RELOC_ABS64 -> @"System.String System.String::FastAllocateString(System.Int32)" + 0
118+
# nextln: 000199: 4c 89 ef mov rdi, r13
119+
# nextln: 00019c: ff d0 call rax
120+
# nextln: 00019e: 49 89 c6 mov r14, rax
121+
# nextln: 0001a1: 49 89 df mov r15, rbx
122+
# nextln: 0001a4: 41 8b 4c 24 10 mov ecx, dword ptr [r12 + 0x10]
123+
# nextln: 0001a9: 33 c0 xor eax, eax
124+
# nextln: 0001ab: 44 3b f9 cmp r15d, ecx
125+
# nextln: 0001ae: 0f 9c c0 setl al
126+
# nextln: 0001b1: 0f b6 c0 movzx eax, al
127+
# nextln: 0001b4: 85 c0 test eax, eax
128+
# nextln: 0001b6: 0f 84 b3 00 00 00 je 0x26f
129+
# nextln: 0001bc: 41 8b 4c 24 10 mov ecx, dword ptr [r12 + 0x10]
130+
# nextln: 0001c1: 49 63 c7 movsxd rax, r15d
131+
# nextln: 0001c4: 48 3b c1 cmp rax, rcx
132+
# nextln: 0001c7: 0f 83 94 00 00 00 jae 0x261
133+
# nextln: 0001cd: 48 c1 e0 03 shl rax, 3
134+
# nextln: 0001d1: 48 83 c0 18 add rax, 0x18
135+
# nextln: 0001d5: 4c 89 e1 mov rcx, r12
136+
# nextln: 0001d8: 48 03 c8 add rcx, rax
137+
# nextln: 0001db: 4c 89 24 24 mov qword ptr [rsp], r12
138+
# nextln: 0001df: 48 8b 11 mov rdx, qword ptr [rcx]
139+
# nextln: 0001e2: 48 85 d2 test rdx, rdx
140+
# nextln: 0001e5: 0f 85 0a 00 00 00 jne 0x1f5
141+
# nextln: 0001eb: b8 01 00 00 00 mov eax, 1
142+
# nextln: 0001f0: e9 0a 00 00 00 jmp 0x1ff
143+
# nextln: 0001f5: 8b 4a 10 mov ecx, dword ptr [rdx + 0x10]
144+
# nextln: 0001f8: 33 c0 xor eax, eax
145+
# nextln: 0001fa: 85 c9 test ecx, ecx
146+
# nextln: 0001fc: 0f 94 c0 sete al
147+
# nextln: 0001ff: 0f b6 c8 movzx ecx, al
148+
# nextln: 000202: 33 c0 xor eax, eax
149+
# nextln: 000204: 85 c9 test ecx, ecx
150+
# nextln: 000206: 0f 94 c0 sete al
151+
# nextln: 000209: 0f b6 c0 movzx eax, al
152+
# nextln: 00020c: 85 c0 test eax, eax
153+
# nextln: 00020e: 0f 84 40 00 00 00 je 0x254
154+
# nextln: 000214: 4c 89 e8 mov rax, r13
155+
# nextln: 000217: 2b c3 sub eax, ebx
156+
# nextln: 000219: 44 8b 62 10 mov r12d, dword ptr [rdx + 0x10]
157+
# nextln: 00021d: 33 c9 xor ecx, ecx
158+
# nextln: 00021f: 41 3b c4 cmp eax, r12d
159+
# nextln: 000222: 0f 9c c1 setl cl
160+
# nextln: 000225: 0f b6 c1 movzx eax, cl
161+
# nextln: 000228: 85 c0 test eax, eax
162+
# nextln: 00022a: 0f 85 1a 00 00 00 jne 0x24a
163+
# nextln: 000230: 48 b8 00 00 00 00 00 00 00 00 movabs rax, 0 # RELOC_ABS64 -> @"System.Void System.String::CopyStringContent(System.String, System.Int32, System.String)" + 0
164+
# nextln: 00023a: 4c 89 f7 mov rdi, r14
165+
# nextln: 00023d: 48 89 de mov rsi, rbx
166+
# nextln: 000240: ff d0 call rax
167+
# nextln: 000242: 41 03 dc add ebx, r12d
168+
# nextln: 000245: e9 0a 00 00 00 jmp 0x254
169+
# nextln: 00024a: bb ff ff ff ff mov ebx, 0xffffffff
170+
# nextln: 00024f: e9 1b 00 00 00 jmp 0x26f
171+
# nextln: 000254: 41 83 c7 01 add r15d, 1
172+
# nextln: 000258: 4c 8b 24 24 mov r12, qword ptr [rsp]
173+
# nextln: 00025c: e9 43 ff ff ff jmp 0x1a4
174+
# nextln: 000261: 48 b8 00 00 00 00 00 00 00 00 movabs rax, 0 # RELOC_ABS64 -> @jit_throw_index_out_of_range + 0
175+
# nextln: 00026b: ff d0 call rax
176+
# nextln: 00026d: 0f 0b ud2
177+
# nextln: 00026f: 41 3b dd cmp ebx, r13d
178+
# nextln: 000272: 0f 85 12 00 00 00 jne 0x28a
179+
# nextln: 000278: 4c 89 f0 mov rax, r14
180+
# nextln: 00027b: 48 83 c4 18 add rsp, 0x18
181+
# nextln: 00027f: 5b pop rbx
182+
# nextln: 000280: 41 5c pop r12
183+
# nextln: 000282: 41 5d pop r13
184+
# nextln: 000284: 41 5e pop r14
185+
# nextln: 000286: 41 5f pop r15
186+
# nextln: 000288: 5d pop rbp
187+
# nextln: 000289: c3 ret
188+
# nextln: 00028a: 48 b8 00 00 00 00 00 00 00 00 movabs rax, 0 # RELOC_ABS64 -> @jit_throw + 0
189+
# nextln: 000294: 33 ff xor edi, edi
190+
# nextln: 000296: ff d0 call rax
191+
# nextln: 000298: 0f 0b ud2
192+
193+
%0:ctrl, %1:ptr = entry
194+
%2:ptr = iconst 0
195+
%3:i32 = icmp eq %1, %2
196+
%4:ctrl, %5:phisel = region
197+
%6:ptr = phi %5
198+
%7:i32 = icmp eq %6, %2
199+
%8:ctrl, %9:ctrl = brcond %4, %7
200+
%10:ctrl, %11:ptr = load.8 %9, %6
201+
%12:i32 = iconst 1
202+
%13:i64 = iconst 8
203+
%14:ptr = ptroff %11, %13
204+
%15:ctrl, %16:i64 = load.8 %10, %14
205+
%17:ctrl, %18:ctrl = brcond %15, %12
206+
%19:ctrl, %20:phisel = region %17, %8
207+
%21:ptr = phi %20, %6, %2
208+
%22:ctrl, %23:ptr = call @"System.String System.String::Concat(System.String[])" %19, %21
209+
%24:ctrl = call @jit_throw_invalid_cast %18
210+
unreachable %24
211+
%25:ptr = iconst 136096799136688
212+
%26:i64 = iconst 24
213+
%27:ptr = ptroff %1, %26
214+
%28:i64 = iconst 0
215+
%29:i64 = iconst 16
216+
%30:ptr = ptroff %1, %29
217+
%31:i32 = iconst 255
218+
%32:i32 = and %3, %31
219+
%33:ctrl, %34:ctrl = brcond %0, %32
220+
%35:i32 = iconst 3
221+
%36:i32 = iconst 0
222+
%37:i32 = iconst 4294967295
223+
%38:ctrl, %39:phisel = region
224+
%40:ptr = iconst 137196310807360
225+
%41:i64 = iconst 2147483647
226+
%42:ctrl, %43:phisel = region
227+
%44:ctrl, %45:phisel = region %34, %42
228+
%46:ctrl, %47:i64 = load.4 %44, %30
229+
%48:i32 = itrunc %47
230+
%49:i32 = icmp slt %12, %48
231+
%50:i32 = icmp eq %49, %36
232+
%51:i32 = and %50, %31
233+
%52:ctrl, %53:ctrl = brcond %46, %51
234+
%54:ctrl, %55:i64 = load.4 %52, %30
235+
%56:ctrl, %57:ctrl = brcond %54, %55
236+
%58:ctrl, %59:i64 = load.4 %56, %30
237+
%60:i32 = icmp ne %59, %28
238+
%61:ctrl, %62:ctrl = brcond %58, %60
239+
%63:ctrl, %64:ptr = load.8 %61, %27
240+
%65:i32 = icmp ne %64, %2
241+
%66:ctrl, %67:ctrl = brcond %63, %65
242+
%68:ctrl, %69:ptr = load.8 %67, %25
243+
%70:ctrl, %71:phisel = region %66, %68
244+
%72:ptr = phi %71, %64, %69
245+
%73:ctrl = call @jit_throw_index_out_of_range %62
246+
unreachable %73
247+
%74:ctrl, %75:ptr = load.8 %57, %25
248+
%76:ctrl, %77:phisel = region %70, %74
249+
%78:ptr = phi %77, %72, %75
250+
%79:ctrl, %80:phisel = region %53, %111
251+
%86:i32 = phi %80, %36, %87
252+
%88:i64 = iext %86
253+
%89:i64 = sfill 32 %88
254+
%90:i64 = shl %89, %35
255+
%91:i64 = iadd %90, %26
256+
%87:i32 = iadd %86, %12
257+
%81:ptr = phi %80, %1, %81
258+
%92:ptr = ptroff %81, %91
259+
%82:ptr = ptroff %81, %29
260+
%83:ctrl, %84:i64 = load.4 %79, %82
261+
%85:i32 = itrunc %84
262+
%93:i32 = icmp slt %86, %85
263+
%94:i32 = and %93, %31
264+
%95:ctrl, %96:ctrl = brcond %83, %94
265+
%97:ctrl, %98:i64 = load.4 %95, %82
266+
%99:i32 = icmp ult %89, %98
267+
%100:ctrl, %101:ctrl = brcond %97, %99
268+
%102:ctrl, %103:ptr = load.8 %100, %92
269+
%108:ptr = ptroff %103, %29
270+
%104:i32 = icmp ne %103, %2
271+
%105:i32 = and %104, %31
272+
%106:ctrl, %107:ctrl = brcond %102, %105
273+
%109:ctrl, %110:i32 = load.4 %106, %108
274+
%113:i64 = iext %110
275+
%114:i64 = sfill 32 %113
276+
%111:ctrl, %112:phisel = region %107, %109
277+
%121:i64 = phi %112, %116, %120
278+
%116:i64 = phi %80, %28, %121
279+
%122:i32 = icmp slt %41, %116
280+
%123:i32 = and %122, %31
281+
%120:i64 = iadd %116, %114
282+
%117:i32 = itrunc %116
283+
%118:i32 = icmp eq %117, %36
284+
%119:i32 = and %118, %31
285+
%115:ctrl = call @jit_throw_index_out_of_range %101
286+
unreachable %115
287+
%124:ctrl, %125:ctrl = brcond %96, %123
288+
%126:ctrl, %127:ptr = call @jit_newobj %124, %40
289+
%128:ctrl = call @jit_throw %126, %127
290+
unreachable %128
291+
%129:ctrl, %130:phisel = region %125, %38
292+
%131:ctrl, %132:ctrl = brcond %129, %119
293+
%133:ctrl, %134:ptr = load.8 %131, %25
294+
%135:ctrl, %136:ptr = call @"System.String System.String::FastAllocateString(System.Int32)" %132, %117
295+
%137:ptr = phi %142, %136, %137
296+
%138:ctrl = call @"System.Void System.String::CopyStringContent(System.String, System.Int32, System.String)" %192, %137, %186, %165
297+
%139:ctrl, %140:phisel = region %180, %138
298+
%141:ctrl, %142:phisel = region %135, %139
299+
%184:i32 = phi %142, %117, %184
300+
%148:i32 = phi %142, %36, %149
301+
%150:i64 = iext %148
302+
%151:i64 = sfill 32 %150
303+
%152:i64 = shl %151, %35
304+
%153:i64 = iadd %152, %26
305+
%149:i32 = iadd %148, %12
306+
%143:ptr = phi %142, %81, %143
307+
%154:ptr = ptroff %143, %153
308+
%144:ptr = ptroff %143, %29
309+
%145:ctrl, %146:i64 = load.4 %141, %144
310+
%147:i32 = itrunc %146
311+
%155:i32 = icmp slt %148, %147
312+
%156:i32 = and %155, %31
313+
%157:ctrl, %158:ctrl = brcond %145, %156
314+
%159:ctrl, %160:i64 = load.4 %157, %144
315+
%161:i32 = icmp ult %151, %160
316+
%162:ctrl, %163:ctrl = brcond %159, %161
317+
%164:ctrl, %165:ptr = load.8 %162, %154
318+
%167:i32 = icmp eq %165, %2
319+
%168:ctrl, %169:ctrl = brcond %164, %167
320+
%166:ptr = ptroff %165, %29
321+
%170:ctrl, %171:i32 = load.4 %169, %166
322+
%172:ctrl, %173:phisel = region %170, %168
323+
%174:i32 = icmp eq %171, %36
324+
%175:i32 = phi %173, %174, %12
325+
%176:i32 = and %175, %31
326+
%177:i32 = icmp eq %176, %36
327+
%178:i32 = and %177, %31
328+
%179:ctrl, %180:ctrl = brcond %172, %178
329+
%181:ctrl, %182:i32 = load.4 %179, %166
330+
%183:ctrl = call @jit_throw_index_out_of_range %163
331+
unreachable %183
332+
%185:i32 = phi %140, %186, %187
333+
%186:i32 = phi %142, %36, %185
334+
%188:i32 = isub %184, %186
335+
%189:i32 = icmp slt %188, %182
336+
%190:i32 = and %189, %31
337+
%191:ctrl, %192:ctrl = brcond %181, %190
338+
%193:ctrl, %194:phisel = region %158, %191
339+
%195:i32 = phi %194, %186, %37
340+
%196:i32 = icmp eq %195, %184
341+
%197:ctrl, %198:ctrl = brcond %193, %196
342+
%199:ctrl, %200:phisel = region %22, %197
343+
%201:ctrl, %202:phisel = region %76, %133, %199
344+
%203:ptr = phi %200, %23, %137
345+
%204:ptr = phi %202, %78, %134, %203
346+
return %201, %204
347+
%205:ctrl = call @jit_throw %198, %2
348+
unreachable %205
349+
%187:i32 = iadd %186, %182
350+
%206:ptr = iconst 136234271001616
351+
%207:ptr = iconst 137196310787008
352+
%208:ctrl, %209:ptr = call @jit_newobj %33, %207
353+
%210:ptr = ptroff %209, %29
354+
%211:ctrl = store.8 %208, %206, %210
355+
%212:ctrl = call @jit_throw %211, %209
356+
unreachable %212
357+
}

0 commit comments

Comments
 (0)