Skip to content

Commit 98653db

Browse files
committed
Add more regalloc and codegen tests
The TDN tests were all unoptimized, which resulted in large amounts of redundant constants/computation. Things like that are great for stressing the allocator, but we also want some more true-to-life test cases to assess regalloc quality. While we're at it, add some loop nest tests from TDN, as we don't have any of those yet.
1 parent 0e48051 commit 98653db

13 files changed

+21349
-0
lines changed
Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
# run: codegen
2+
3+
extfunc @malloc:ptr(i64)
4+
5+
func @gc_new:ptr(i32, i64) {
6+
# check: function `gc_new`:
7+
# nextln: 000000: 55 push rbp
8+
# nextln: 000001: 48 89 e5 mov rbp, rsp
9+
# nextln: 000004: 48 89 f7 mov rdi, rsi
10+
# nextln: 000007: 48 b8 00 00 00 00 00 00 00 00 movabs rax, 0 # RELOC_ABS64 -> @malloc + 0
11+
# nextln: 000011: ff d0 call rax
12+
# nextln: 000013: 5d pop rbp
13+
# nextln: 000014: c3 ret
14+
15+
%0:ctrl, %1:i32, %2:i64 = entry
16+
%3:ctrl, %4:ptr = call @malloc %0, %2
17+
return %3, %4
18+
}
19+
20+
func @throw_index_out_of_range_exception() {
21+
# check: function `throw_index_out_of_range_exception`:
22+
# nextln: 000000: 55 push rbp
23+
# nextln: 000001: 48 89 e5 mov rbp, rsp
24+
# nextln: 000004: 5d pop rbp
25+
# nextln: 000005: c3 ret
26+
27+
%0:ctrl = entry
28+
return %0
29+
}
30+
31+
func @"System.Int32 Tests.CodeGenBringUpTests::ArrayJagged(System.Int32)":i32(i32) {
32+
# check: function `System.Int32 Tests.CodeGenBringUpTests::ArrayJagged(System.Int32)`:
33+
# nextln: 000000: 55 push rbp
34+
# nextln: 000001: 48 89 e5 mov rbp, rsp
35+
# nextln: 000004: 41 57 push r15
36+
# nextln: 000006: 41 56 push r14
37+
# nextln: 000008: 41 55 push r13
38+
# nextln: 00000a: 41 54 push r12
39+
# nextln: 00000c: 53 push rbx
40+
# nextln: 00000d: 48 83 ec 18 sub rsp, 0x18
41+
# nextln: 000011: 48 89 7c 24 08 mov qword ptr [rsp + 8], rdi
42+
# nextln: 000016: 41 bc aa 00 00 00 mov r12d, 0xaa
43+
# nextln: 00001c: 41 bd 1c 00 00 00 mov r13d, 0x1c
44+
# nextln: 000022: be 28 00 00 00 mov esi, 0x28
45+
# nextln: 000027: bf ab 00 00 00 mov edi, 0xab
46+
# nextln: 00002c: 41 bf 02 00 00 00 mov r15d, 2
47+
# nextln: 000032: 41 be 01 00 00 00 mov r14d, 1
48+
# nextln: 000038: 33 c0 xor eax, eax
49+
# nextln: 00003a: 48 89 04 24 mov qword ptr [rsp], rax
50+
# nextln: 00003e: e8 00 00 00 00 call 0x43 # RELOC_PC32 -> @gc_new + -4
51+
# nextln: 000043: 48 89 c1 mov rcx, rax
52+
# nextln: 000046: 48 83 c1 10 add rcx, 0x10
53+
# nextln: 00004a: 44 89 39 mov dword ptr [rcx], r15d
54+
# nextln: 00004d: 48 89 04 24 mov qword ptr [rsp], rax
55+
# nextln: 000051: 48 8b 1c 24 mov rbx, qword ptr [rsp]
56+
# nextln: 000055: 4c 89 ee mov rsi, r13
57+
# nextln: 000058: 4c 89 e7 mov rdi, r12
58+
# nextln: 00005b: e8 00 00 00 00 call 0x60 # RELOC_PC32 -> @gc_new + -4
59+
# nextln: 000060: 48 89 c1 mov rcx, rax
60+
# nextln: 000063: 48 83 c1 10 add rcx, 0x10
61+
# nextln: 000067: 44 89 39 mov dword ptr [rcx], r15d
62+
# nextln: 00006a: 8b 09 mov ecx, dword ptr [rcx]
63+
# nextln: 00006c: 4c 3b f1 cmp r14, rcx
64+
# nextln: 00006f: 0f 8d de 00 00 00 jge 0x153
65+
# nextln: 000075: 48 89 d9 mov rcx, rbx
66+
# nextln: 000078: 48 83 c1 10 add rcx, 0x10
67+
# nextln: 00007c: 48 89 c2 mov rdx, rax
68+
# nextln: 00007f: 48 83 c2 18 add rdx, 0x18
69+
# nextln: 000083: bf 01 00 00 00 mov edi, 1
70+
# nextln: 000088: 89 3a mov dword ptr [rdx], edi
71+
# nextln: 00008a: 8b 09 mov ecx, dword ptr [rcx]
72+
# nextln: 00008c: 48 85 c9 test rcx, rcx
73+
# nextln: 00008f: 0f 8e be 00 00 00 jle 0x153
74+
# nextln: 000095: 48 83 c3 18 add rbx, 0x18
75+
# nextln: 000099: 48 89 03 mov qword ptr [rbx], rax
76+
# nextln: 00009c: 48 8b 1c 24 mov rbx, qword ptr [rsp]
77+
# nextln: 0000a0: 4c 89 ee mov rsi, r13
78+
# nextln: 0000a3: 4c 89 e7 mov rdi, r12
79+
# nextln: 0000a6: e8 00 00 00 00 call 0xab # RELOC_PC32 -> @gc_new + -4
80+
# nextln: 0000ab: 48 89 c1 mov rcx, rax
81+
# nextln: 0000ae: 48 83 c1 10 add rcx, 0x10
82+
# nextln: 0000b2: 44 89 39 mov dword ptr [rcx], r15d
83+
# nextln: 0000b5: 8b 11 mov edx, dword ptr [rcx]
84+
# nextln: 0000b7: 48 85 d2 test rdx, rdx
85+
# nextln: 0000ba: 0f 8e 93 00 00 00 jle 0x153
86+
# nextln: 0000c0: 48 89 c2 mov rdx, rax
87+
# nextln: 0000c3: 48 83 c2 14 add rdx, 0x14
88+
# nextln: 0000c7: bf 02 00 00 00 mov edi, 2
89+
# nextln: 0000cc: 89 3a mov dword ptr [rdx], edi
90+
# nextln: 0000ce: 8b 09 mov ecx, dword ptr [rcx]
91+
# nextln: 0000d0: 4c 3b f1 cmp r14, rcx
92+
# nextln: 0000d3: 0f 8d 7a 00 00 00 jge 0x153
93+
# nextln: 0000d9: 48 89 d9 mov rcx, rbx
94+
# nextln: 0000dc: 48 83 c1 10 add rcx, 0x10
95+
# nextln: 0000e0: 48 89 c2 mov rdx, rax
96+
# nextln: 0000e3: 48 83 c2 18 add rdx, 0x18
97+
# nextln: 0000e7: bf 03 00 00 00 mov edi, 3
98+
# nextln: 0000ec: 89 3a mov dword ptr [rdx], edi
99+
# nextln: 0000ee: 8b 09 mov ecx, dword ptr [rcx]
100+
# nextln: 0000f0: 4c 3b f1 cmp r14, rcx
101+
# nextln: 0000f3: 0f 8d 5a 00 00 00 jge 0x153
102+
# nextln: 0000f9: 48 83 c3 20 add rbx, 0x20
103+
# nextln: 0000fd: 48 89 03 mov qword ptr [rbx], rax
104+
# nextln: 000100: 48 8b 04 24 mov rax, qword ptr [rsp]
105+
# nextln: 000104: 48 89 c1 mov rcx, rax
106+
# nextln: 000107: 48 83 c1 10 add rcx, 0x10
107+
# nextln: 00010b: 8b 09 mov ecx, dword ptr [rcx]
108+
# nextln: 00010d: 4c 3b f1 cmp r14, rcx
109+
# nextln: 000110: 0f 8d 3d 00 00 00 jge 0x153
110+
# nextln: 000116: 48 83 c0 20 add rax, 0x20
111+
# nextln: 00011a: 48 8b 00 mov rax, qword ptr [rax]
112+
# nextln: 00011d: 48 89 c1 mov rcx, rax
113+
# nextln: 000120: 48 83 c1 10 add rcx, 0x10
114+
# nextln: 000124: 8b 11 mov edx, dword ptr [rcx]
115+
# nextln: 000126: 48 8b 4c 24 08 mov rcx, qword ptr [rsp + 8]
116+
# nextln: 00012b: 48 63 c9 movsxd rcx, ecx
117+
# nextln: 00012e: 48 3b ca cmp rcx, rdx
118+
# nextln: 000131: 0f 8d 1c 00 00 00 jge 0x153
119+
# nextln: 000137: 48 c1 e1 02 shl rcx, 2
120+
# nextln: 00013b: 48 83 c1 14 add rcx, 0x14
121+
# nextln: 00013f: 48 03 c1 add rax, rcx
122+
# nextln: 000142: 8b 00 mov eax, dword ptr [rax]
123+
# nextln: 000144: 48 83 c4 18 add rsp, 0x18
124+
# nextln: 000148: 5b pop rbx
125+
# nextln: 000149: 41 5c pop r12
126+
# nextln: 00014b: 41 5d pop r13
127+
# nextln: 00014d: 41 5e pop r14
128+
# nextln: 00014f: 41 5f pop r15
129+
# nextln: 000151: 5d pop rbp
130+
# nextln: 000152: c3 ret
131+
# nextln: 000153: e8 00 00 00 00 call 0x158 # RELOC_PC32 -> @throw_index_out_of_range_exception + -4
132+
# nextln: 000158: 0f 0b ud2
133+
134+
%0:ctrl, %1:i32 = entry
135+
%20:ptr = stackslot 8:8
136+
%4:i64 = iext %1
137+
%5:i64 = sfill 32 %4
138+
%8:i64 = iconst 20
139+
%29:i32 = iconst 2
140+
%140:i64 = shl %5, %29
141+
%9:i64 = iadd %140, %8
142+
%10:i64 = iconst 16
143+
%135:i64 = iconst 32
144+
%133:i64 = iconst 1
145+
%134:i64 = iconst 24
146+
%21:i32 = iconst 3
147+
%136:i64 = iconst 0
148+
%137:i64 = iconst 2
149+
%138:i64 = iconst 28
150+
%36:i32 = iconst 170
151+
%11:i32 = iconst 1
152+
%139:i64 = iconst 40
153+
%37:i32 = iconst 171
154+
%38:ptr = iconst 0
155+
%39:ctrl = store.8 %0, %38, %20
156+
%42:ctrl, %43:ptr = call @gc_new %39, %37, %139
157+
%44:ptr = ptroff %43, %10
158+
%45:ctrl = store.4 %42, %137, %44
159+
%46:ctrl = store.8 %45, %43, %20
160+
%47:ctrl, %48:ptr = load.8 %46, %20
161+
%49:ctrl, %50:ptr = call @gc_new %47, %36, %138
162+
%60:ptr = ptroff %50, %134
163+
%51:ptr = ptroff %50, %10
164+
%52:ctrl = store.4 %49, %137, %51
165+
%53:ctrl, %54:i64 = load.4 %52, %51
166+
%55:i64 = icmp slt %133, %54
167+
%56:ctrl, %57:ctrl = brcond %53, %55
168+
%61:ctrl = store.4 %56, %11, %60
169+
%70:ptr = ptroff %48, %134
170+
%62:ptr = ptroff %48, %10
171+
%63:ctrl, %64:i64 = load.4 %61, %62
172+
%65:i64 = icmp slt %136, %64
173+
%66:ctrl, %67:ctrl = brcond %63, %65
174+
%71:ctrl = store.8 %66, %50, %70
175+
%72:ctrl, %73:ptr = load.8 %71, %20
176+
%74:ctrl, %75:ptr = call @gc_new %72, %36, %138
177+
%94:ptr = ptroff %75, %134
178+
%85:ptr = ptroff %75, %8
179+
%76:ptr = ptroff %75, %10
180+
%77:ctrl = store.4 %74, %137, %76
181+
%78:ctrl, %79:i64 = load.4 %77, %76
182+
%80:i64 = icmp slt %136, %79
183+
%81:ctrl, %82:ctrl = brcond %78, %80
184+
%86:ctrl = store.4 %81, %29, %85
185+
%87:ctrl, %88:i64 = load.4 %86, %76
186+
%89:i64 = icmp slt %133, %88
187+
%90:ctrl, %91:ctrl = brcond %87, %89
188+
%95:ctrl = store.4 %90, %21, %94
189+
%104:ptr = ptroff %73, %135
190+
%96:ptr = ptroff %73, %10
191+
%97:ctrl, %98:i64 = load.4 %95, %96
192+
%99:i64 = icmp slt %133, %98
193+
%100:ctrl, %101:ctrl = brcond %97, %99
194+
%105:ctrl = store.8 %100, %75, %104
195+
%106:ctrl, %107:ptr = load.8 %105, %20
196+
%116:ptr = ptroff %107, %135
197+
%108:ptr = ptroff %107, %10
198+
%109:ctrl, %110:i64 = load.4 %106, %108
199+
%111:i64 = icmp slt %133, %110
200+
%112:ctrl, %113:ctrl = brcond %109, %111
201+
%117:ctrl, %118:ptr = load.8 %112, %116
202+
%130:ptr = ptroff %118, %9
203+
%119:ptr = ptroff %118, %10
204+
%120:ctrl, %121:i64 = load.4 %117, %119
205+
%122:i64 = icmp slt %5, %121
206+
%123:ctrl, %124:ctrl = brcond %120, %122
207+
%131:ctrl, %132:i32 = load.4 %123, %130
208+
return %131, %132
209+
%127:ctrl, %128:phisel = region %57, %67, %82, %91, %101, %113, %124
210+
%129:ctrl = call @throw_index_out_of_range_exception %127
211+
unreachable %129
212+
}

0 commit comments

Comments
 (0)