-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: also test the
debugPrintf
generated from panics.
- Loading branch information
1 parent
6e65769
commit d90a4d0
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#![crate_name = "panic_builtin_bounds_check"] | ||
|
||
// Test that bounds checking panics get converted to `debugPrintf` correctly. | ||
|
||
// build-pass | ||
// compile-flags: -C target-feature=+ext:SPV_KHR_non_semantic_info | ||
// compile-flags: -C llvm-args=--abort-strategy=debug-printf | ||
// compile-flags: -C llvm-args=--disassemble | ||
|
||
// FIXME(eddyb) consider using such replacements also for dealing | ||
// with `OpLine` changing all the time (esp. in libcore functions). | ||
// | ||
// normalize-stderr-test "; (SPIR-V|Generator: rspirv|Version: 1\.\d+|Bound: \d+)\n" -> "" | ||
// normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" | ||
// normalize-stderr-test "OpSource .*\n" -> "" | ||
// normalize-stderr-test "OpExtension .SPV_KHR_vulkan_memory_model.\n" -> "" | ||
// normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" | ||
|
||
// FIXME(eddyb) handle this one in the test runner. | ||
// normalize-stderr-test "\S*/lib/rustlib/" -> "$$SYSROOT/lib/rustlib/" | ||
|
||
use spirv_std::spirv; | ||
|
||
fn array_bounds_check(x: [u32; 4], i: usize) -> u32 { | ||
x[i] | ||
} | ||
|
||
#[spirv(fragment)] | ||
pub fn main() { | ||
array_bounds_check([0, 1, 2, 3], 5); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
OpCapability Shader | ||
OpCapability Float64 | ||
OpCapability Int64 | ||
OpCapability Int16 | ||
OpCapability Int8 | ||
OpCapability ShaderClockKHR | ||
OpExtension "SPV_KHR_non_semantic_info" | ||
OpExtension "SPV_KHR_shader_clock" | ||
%1 = OpExtInstImport "NonSemantic.DebugPrintf" | ||
OpMemoryModel Logical Simple | ||
OpEntryPoint Fragment %2 "main" | ||
OpExecutionMode %2 OriginUpperLeft | ||
%3 = OpString "/n[Rust panicked at $SYSROOT/lib/rustlib/src/rust/library/core/src/panicking.rs:180:5]/n index out of bounds: the len is %u but the index is %u/n in main()/n" | ||
%4 = OpString $SYSROOT/lib/rustlib/src/rust/library/core/src/panicking.rs" | ||
%5 = OpString "$DIR/panic_builtin_bounds_check.rs" | ||
%6 = OpTypeVoid | ||
%7 = OpTypeFunction %6 | ||
%8 = OpTypeBool | ||
%9 = OpTypeInt 32 0 | ||
%10 = OpConstant %9 5 | ||
%11 = OpConstant %9 4 | ||
%2 = OpFunction %6 None %7 | ||
%12 = OpLabel | ||
OpLine %5 25 4 | ||
%13 = OpULessThan %8 %10 %11 | ||
OpNoLine | ||
OpSelectionMerge %14 None | ||
OpBranchConditional %13 %15 %16 | ||
%15 = OpLabel | ||
OpBranch %14 | ||
%16 = OpLabel | ||
OpLine %4 180 4 | ||
%17 = OpExtInst %6 %1 1 %3 %11 %10 | ||
OpNoLine | ||
OpBranch %14 | ||
%14 = OpLabel | ||
OpReturn | ||
OpFunctionEnd |