Skip to content

Commit 1faeac1

Browse files
eddybLegNeato
authored andcommitted
tests: add test for long chain of conditional panics.
1 parent 5354c97 commit 1faeac1

File tree

2 files changed

+311
-0
lines changed

2 files changed

+311
-0
lines changed

tests/ui/dis/panic_sequential_many.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#![crate_name = "panic_sequential_many"]
2+
3+
// Test a long sequence of conditional panics, which has historically generated
4+
// very nested structured control-flow (instead of a single merged chain).
5+
6+
// build-pass
7+
// compile-flags: -C target-feature=+ext:SPV_KHR_non_semantic_info
8+
// compile-flags: -C llvm-args=--abort-strategy=debug-printf
9+
// compile-flags: -C llvm-args=--disassemble
10+
11+
// FIXME(eddyb) consider using such replacements also for dealing
12+
// with `OpLine` changing all the time (esp. in libcore functions).
13+
//
14+
// normalize-stderr-test "; (SPIR-V|Generator: rspirv|Version: 1\.\d+|Bound: \d+)\n" -> ""
15+
// normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> ""
16+
// normalize-stderr-test "OpSource .*\n" -> ""
17+
// normalize-stderr-test "OpExtension .SPV_KHR_vulkan_memory_model.\n" -> ""
18+
// normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple"
19+
20+
// FIXME(eddyb) handle this one in the test runner.
21+
// normalize-stderr-test "\S*/lib/rustlib/" -> "$$SYSROOT/lib/rustlib/"
22+
23+
use spirv_std::spirv;
24+
25+
#[spirv(fragment)]
26+
pub fn main(#[spirv(flat)] x: u32, #[spirv(flat)] y: u32, o: &mut u32) {
27+
// HACK(eddyb) this might stop working if the checks get optimized out,
28+
// after the first `y != 0` (which dominates the rest of the function).
29+
*o = x / y / y / y / y / y / y / y / y / y / y / y / y / y / y / y / y / y;
30+
}
Lines changed: 281 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,281 @@
1+
OpCapability Shader
2+
OpCapability Float64
3+
OpCapability Int64
4+
OpCapability Int16
5+
OpCapability Int8
6+
OpCapability ShaderClockKHR
7+
OpExtension "SPV_KHR_non_semantic_info"
8+
OpExtension "SPV_KHR_shader_clock"
9+
%1 = OpExtInstImport "NonSemantic.DebugPrintf"
10+
OpMemoryModel Logical Simple
11+
OpEntryPoint Fragment %2 "main" %3 %4 %5
12+
OpExecutionMode %2 OriginUpperLeft
13+
%6 = OpString "/n[Rust panicked at $DIR/panic_sequential_many.rs:29:10]/n attempt to divide by zero/n in main()/n"
14+
%7 = OpString "$DIR/panic_sequential_many.rs"
15+
OpName %3 "x"
16+
OpName %4 "y"
17+
OpName %5 "o"
18+
OpDecorate %3 Flat
19+
OpDecorate %3 Location 0
20+
OpDecorate %4 Flat
21+
OpDecorate %4 Location 1
22+
OpDecorate %5 Location 0
23+
%8 = OpTypeInt 32 0
24+
%9 = OpTypePointer Input %8
25+
%10 = OpTypePointer Output %8
26+
%11 = OpTypeVoid
27+
%12 = OpTypeFunction %11
28+
%3 = OpVariable %9 Input
29+
%4 = OpVariable %9 Input
30+
%13 = OpTypeBool
31+
%14 = OpConstant %8 0
32+
%5 = OpVariable %10 Output
33+
%2 = OpFunction %11 None %12
34+
%15 = OpLabel
35+
OpLine %7 26 12
36+
%16 = OpLoad %8 %3
37+
OpLine %7 26 35
38+
%17 = OpLoad %8 %4
39+
OpLine %7 29 9
40+
%18 = OpIEqual %13 %17 %14
41+
OpNoLine
42+
OpSelectionMerge %19 None
43+
OpBranchConditional %18 %20 %21
44+
%20 = OpLabel
45+
OpLine %7 29 9
46+
%22 = OpExtInst %11 %1 1 %6
47+
OpNoLine
48+
OpBranch %19
49+
%21 = OpLabel
50+
OpLine %7 29 9
51+
%23 = OpUDiv %8 %16 %17
52+
%24 = OpIEqual %13 %17 %14
53+
OpNoLine
54+
OpSelectionMerge %25 None
55+
OpBranchConditional %24 %26 %27
56+
%26 = OpLabel
57+
OpLine %7 29 9
58+
%28 = OpExtInst %11 %1 1 %6
59+
OpNoLine
60+
OpBranch %25
61+
%27 = OpLabel
62+
OpLine %7 29 9
63+
%29 = OpUDiv %8 %23 %17
64+
%30 = OpIEqual %13 %17 %14
65+
OpNoLine
66+
OpSelectionMerge %31 None
67+
OpBranchConditional %30 %32 %33
68+
%32 = OpLabel
69+
OpLine %7 29 9
70+
%34 = OpExtInst %11 %1 1 %6
71+
OpNoLine
72+
OpBranch %31
73+
%33 = OpLabel
74+
OpLine %7 29 9
75+
%35 = OpUDiv %8 %29 %17
76+
%36 = OpIEqual %13 %17 %14
77+
OpNoLine
78+
OpSelectionMerge %37 None
79+
OpBranchConditional %36 %38 %39
80+
%38 = OpLabel
81+
OpLine %7 29 9
82+
%40 = OpExtInst %11 %1 1 %6
83+
OpNoLine
84+
OpBranch %37
85+
%39 = OpLabel
86+
OpLine %7 29 9
87+
%41 = OpUDiv %8 %35 %17
88+
%42 = OpIEqual %13 %17 %14
89+
OpNoLine
90+
OpSelectionMerge %43 None
91+
OpBranchConditional %42 %44 %45
92+
%44 = OpLabel
93+
OpLine %7 29 9
94+
%46 = OpExtInst %11 %1 1 %6
95+
OpNoLine
96+
OpBranch %43
97+
%45 = OpLabel
98+
OpLine %7 29 9
99+
%47 = OpUDiv %8 %41 %17
100+
%48 = OpIEqual %13 %17 %14
101+
OpNoLine
102+
OpSelectionMerge %49 None
103+
OpBranchConditional %48 %50 %51
104+
%50 = OpLabel
105+
OpLine %7 29 9
106+
%52 = OpExtInst %11 %1 1 %6
107+
OpNoLine
108+
OpBranch %49
109+
%51 = OpLabel
110+
OpLine %7 29 9
111+
%53 = OpUDiv %8 %47 %17
112+
%54 = OpIEqual %13 %17 %14
113+
OpNoLine
114+
OpSelectionMerge %55 None
115+
OpBranchConditional %54 %56 %57
116+
%56 = OpLabel
117+
OpLine %7 29 9
118+
%58 = OpExtInst %11 %1 1 %6
119+
OpNoLine
120+
OpBranch %55
121+
%57 = OpLabel
122+
OpLine %7 29 9
123+
%59 = OpUDiv %8 %53 %17
124+
%60 = OpIEqual %13 %17 %14
125+
OpNoLine
126+
OpSelectionMerge %61 None
127+
OpBranchConditional %60 %62 %63
128+
%62 = OpLabel
129+
OpLine %7 29 9
130+
%64 = OpExtInst %11 %1 1 %6
131+
OpNoLine
132+
OpBranch %61
133+
%63 = OpLabel
134+
OpLine %7 29 9
135+
%65 = OpUDiv %8 %59 %17
136+
%66 = OpIEqual %13 %17 %14
137+
OpNoLine
138+
OpSelectionMerge %67 None
139+
OpBranchConditional %66 %68 %69
140+
%68 = OpLabel
141+
OpLine %7 29 9
142+
%70 = OpExtInst %11 %1 1 %6
143+
OpNoLine
144+
OpBranch %67
145+
%69 = OpLabel
146+
OpLine %7 29 9
147+
%71 = OpUDiv %8 %65 %17
148+
%72 = OpIEqual %13 %17 %14
149+
OpNoLine
150+
OpSelectionMerge %73 None
151+
OpBranchConditional %72 %74 %75
152+
%74 = OpLabel
153+
OpLine %7 29 9
154+
%76 = OpExtInst %11 %1 1 %6
155+
OpNoLine
156+
OpBranch %73
157+
%75 = OpLabel
158+
OpLine %7 29 9
159+
%77 = OpUDiv %8 %71 %17
160+
%78 = OpIEqual %13 %17 %14
161+
OpNoLine
162+
OpSelectionMerge %79 None
163+
OpBranchConditional %78 %80 %81
164+
%80 = OpLabel
165+
OpLine %7 29 9
166+
%82 = OpExtInst %11 %1 1 %6
167+
OpNoLine
168+
OpBranch %79
169+
%81 = OpLabel
170+
OpLine %7 29 9
171+
%83 = OpUDiv %8 %77 %17
172+
%84 = OpIEqual %13 %17 %14
173+
OpNoLine
174+
OpSelectionMerge %85 None
175+
OpBranchConditional %84 %86 %87
176+
%86 = OpLabel
177+
OpLine %7 29 9
178+
%88 = OpExtInst %11 %1 1 %6
179+
OpNoLine
180+
OpBranch %85
181+
%87 = OpLabel
182+
OpLine %7 29 9
183+
%89 = OpUDiv %8 %83 %17
184+
%90 = OpIEqual %13 %17 %14
185+
OpNoLine
186+
OpSelectionMerge %91 None
187+
OpBranchConditional %90 %92 %93
188+
%92 = OpLabel
189+
OpLine %7 29 9
190+
%94 = OpExtInst %11 %1 1 %6
191+
OpNoLine
192+
OpBranch %91
193+
%93 = OpLabel
194+
OpLine %7 29 9
195+
%95 = OpUDiv %8 %89 %17
196+
%96 = OpIEqual %13 %17 %14
197+
OpNoLine
198+
OpSelectionMerge %97 None
199+
OpBranchConditional %96 %98 %99
200+
%98 = OpLabel
201+
OpLine %7 29 9
202+
%100 = OpExtInst %11 %1 1 %6
203+
OpNoLine
204+
OpBranch %97
205+
%99 = OpLabel
206+
OpLine %7 29 9
207+
%101 = OpUDiv %8 %95 %17
208+
%102 = OpIEqual %13 %17 %14
209+
OpNoLine
210+
OpSelectionMerge %103 None
211+
OpBranchConditional %102 %104 %105
212+
%104 = OpLabel
213+
OpLine %7 29 9
214+
%106 = OpExtInst %11 %1 1 %6
215+
OpNoLine
216+
OpBranch %103
217+
%105 = OpLabel
218+
OpLine %7 29 9
219+
%107 = OpUDiv %8 %101 %17
220+
%108 = OpIEqual %13 %17 %14
221+
OpNoLine
222+
OpSelectionMerge %109 None
223+
OpBranchConditional %108 %110 %111
224+
%110 = OpLabel
225+
OpLine %7 29 9
226+
%112 = OpExtInst %11 %1 1 %6
227+
OpNoLine
228+
OpBranch %109
229+
%111 = OpLabel
230+
OpLine %7 29 9
231+
%113 = OpUDiv %8 %107 %17
232+
%114 = OpIEqual %13 %17 %14
233+
OpNoLine
234+
OpSelectionMerge %115 None
235+
OpBranchConditional %114 %116 %117
236+
%116 = OpLabel
237+
OpLine %7 29 9
238+
%118 = OpExtInst %11 %1 1 %6
239+
OpNoLine
240+
OpBranch %115
241+
%117 = OpLabel
242+
OpLine %7 29 4
243+
%119 = OpUDiv %8 %113 %17
244+
OpStore %5 %119
245+
OpNoLine
246+
OpBranch %115
247+
%115 = OpLabel
248+
OpBranch %109
249+
%109 = OpLabel
250+
OpBranch %103
251+
%103 = OpLabel
252+
OpBranch %97
253+
%97 = OpLabel
254+
OpBranch %91
255+
%91 = OpLabel
256+
OpBranch %85
257+
%85 = OpLabel
258+
OpBranch %79
259+
%79 = OpLabel
260+
OpBranch %73
261+
%73 = OpLabel
262+
OpBranch %67
263+
%67 = OpLabel
264+
OpBranch %61
265+
%61 = OpLabel
266+
OpBranch %55
267+
%55 = OpLabel
268+
OpBranch %49
269+
%49 = OpLabel
270+
OpBranch %43
271+
%43 = OpLabel
272+
OpBranch %37
273+
%37 = OpLabel
274+
OpBranch %31
275+
%31 = OpLabel
276+
OpBranch %25
277+
%25 = OpLabel
278+
OpBranch %19
279+
%19 = OpLabel
280+
OpReturn
281+
OpFunctionEnd

0 commit comments

Comments
 (0)