diff --git a/Cargo.lock b/Cargo.lock index 62518ebc74..1c681cfee0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -683,6 +683,16 @@ version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" +[[package]] +name = "elsa" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b4b5d23ed6b6948d68240aafa4ac98e568c9a020efd9d4201a6288bc3006e09" +dependencies = [ + "indexmap", + "stable_deref_trait", +] + [[package]] name = "encoding_rs" version = "0.8.30" @@ -1096,6 +1106,15 @@ dependencies = [ "web-sys", ] +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "0.4.8" @@ -2007,6 +2026,7 @@ dependencies = [ "serde", "serde_json", "smallvec", + "spirt", "spirv-tools", "syn", "tempfile", @@ -2190,6 +2210,9 @@ name = "smallvec" version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" +dependencies = [ + "serde", +] [[package]] name = "smithay-client-toolkit" @@ -2210,6 +2233,23 @@ dependencies = [ "wayland-protocols 0.29.1", ] +[[package]] +name = "spirt" +version = "0.1.0" +source = "git+https://github.com/EmbarkStudios/spirt.git?rev=cda161b7e7b336685448ab0a7f8cfe96bd90e752#cda161b7e7b336685448ab0a7f8cfe96bd90e752" +dependencies = [ + "arrayvec", + "bytemuck", + "elsa", + "indexmap", + "itertools", + "lazy_static", + "rustc-hash", + "serde", + "serde_json", + "smallvec", +] + [[package]] name = "spirv" version = "0.2.0+1.5.4" @@ -2278,6 +2318,12 @@ dependencies = [ "cc", ] +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "strsim" version = "0.8.0" diff --git a/Cargo.toml b/Cargo.toml index da67f3f6d0..844a54a611 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,3 +52,7 @@ codegen-units = 256 opt-level = 3 incremental = true codegen-units = 256 + +[patch.crates-io] +# HACK(eddyb) only needed until `spirt 0.1.0` is released. +spirt = { git = "https://github.com/EmbarkStudios/spirt.git", rev = "cda161b7e7b336685448ab0a7f8cfe96bd90e752" } diff --git a/crates/rustc_codegen_spirv/Cargo.toml b/crates/rustc_codegen_spirv/Cargo.toml index 0cb07cdd6f..db42aa29a9 100644 --- a/crates/rustc_codegen_spirv/Cargo.toml +++ b/crates/rustc_codegen_spirv/Cargo.toml @@ -56,6 +56,7 @@ serde_json = "1.0" smallvec = { version = "1.6.1", features = ["union"] } spirv-tools = { version = "0.9", default-features = false } rustc_codegen_spirv-types.workspace = true +spirt = "0.1.0" [dev-dependencies] pipe = "0.4" diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs b/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs index 1aaf294a07..0075acdf86 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs @@ -351,6 +351,12 @@ impl CodegenArgs { ); opts.optflag("", "no-structurize", "disables CFG structurization"); + opts.optflag( + "", + "spirt", + "use SPIR-T for legalization (see also `docs/src/codegen-args.md`)", + ); + // NOTE(eddyb) these are debugging options that used to be env vars // (for more information see `docs/src/codegen-args.md`). opts.optopt( @@ -365,6 +371,12 @@ impl CodegenArgs { "dump modules immediately after multimodule splitting, to files in DIR", "DIR", ); + opts.optopt( + "", + "dump-spirt-passes", + "dump the SPIR-T module across passes, to FILE and FILE.html", + "FILE", + ); opts.optflag( "", "specializer-debug", @@ -511,6 +523,7 @@ impl CodegenArgs { dce: !matches.opt_present("no-dce"), compact_ids: !matches.opt_present("no-compact-ids"), structurize: !matches.opt_present("no-structurize"), + spirt: matches.opt_present("spirt"), // FIXME(eddyb) deduplicate between `CodegenArgs` and `linker::Options`. emit_multiple_modules: module_output_type == ModuleOutputType::Multiple, @@ -521,6 +534,7 @@ impl CodegenArgs { // (for more information see `docs/src/codegen-args.md`). dump_post_merge: matches_opt_path("dump-post-merge"), dump_post_split: matches_opt_dump_dir_path("dump-post-split"), + dump_spirt_passes: matches_opt_path("dump-spirt-passes"), specializer_debug: matches.opt_present("specializer-debug"), specializer_dump_instances: matches_opt_path("specializer-dump-instances"), print_all_zombie: matches.opt_present("print-all-zombie"), diff --git a/crates/rustc_codegen_spirv/src/linker/mod.rs b/crates/rustc_codegen_spirv/src/linker/mod.rs index af44ce87d0..d4e3a6577e 100644 --- a/crates/rustc_codegen_spirv/src/linker/mod.rs +++ b/crates/rustc_codegen_spirv/src/linker/mod.rs @@ -34,6 +34,7 @@ pub struct Options { pub compact_ids: bool, pub dce: bool, pub structurize: bool, + pub spirt: bool, pub emit_multiple_modules: bool, pub spirv_metadata: SpirvMetadata, @@ -48,6 +49,7 @@ pub struct Options { // (for more information see `docs/src/codegen-args.md`). pub dump_post_merge: Option, pub dump_post_split: Option, + pub dump_spirt_passes: Option, pub specializer_debug: bool, pub specializer_dump_instances: Option, pub print_all_zombie: bool, @@ -141,10 +143,10 @@ pub fn link(sess: &Session, mut inputs: Vec, opts: &Options) -> Result, opts: &Options) -> Result { + pointer_to_pointee + .insert(inst.result_id.unwrap(), inst.operands[1].unwrap_id_ref()); + } + Op::TypeInt + if inst.operands[0].unwrap_literal_int32() == 32 + && inst.operands[1].unwrap_literal_int32() == 0 => + { + assert!(u32.is_none()); + u32 = Some(inst.result_id.unwrap()); + } + Op::Constant if u32.is_some() && inst.result_type == u32 => { + let value = inst.operands[0].unwrap_literal_int32(); + constants.insert(inst.result_id.unwrap(), value); + } + _ => {} + } + } + for func in &mut output.functions { + simple_passes::block_ordering_pass(func); + // Note: mem2reg requires functions to be in RPO order (i.e. block_ordering_pass) + mem2reg::mem2reg( + output.header.as_mut().unwrap(), + &mut output.types_global_values, + &pointer_to_pointee, + &constants, + func, + ); + destructure_composites::destructure_composites(func); + } + } + { let _timer = sess.timer("link_inline"); inline::inline(sess, &mut output)?; } if opts.dce { - let _timer = sess.timer("link_dce"); + let _timer = sess.timer("link_dce-after-inlining"); dce::dce(&mut output); } - let mut output = if opts.structurize { + let mut output = if opts.structurize && !opts.spirt { let _timer = sess.timer("link_structurize"); structurizer::structurize(output) } else { @@ -252,7 +299,7 @@ pub fn link(sess: &Session, mut inputs: Vec, opts: &Options) -> Result, opts: &Options) -> Result module, + Err(e) => { + use rspirv::binary::Disassemble; + + return Err(sess + .struct_err(format!("{e}")) + .note(format!( + "while lowering this SPIR-V module to SPIR-T:\n{}", + output.disassemble() + )) + .emit()); + } + } + }; + after_pass("lower_from_spv", &module); + + if opts.structurize { + { + let _timer = sess.timer("spirt::legalize::structurize_func_cfgs"); + spirt::passes::legalize::structurize_func_cfgs(&mut module); + } + after_pass("structurize_func_cfgs", &module); + } + + // NOTE(eddyb) this should be *before* `lift_to_spv` below, + // so if that fails, the dump could be used to debug it. + if let Some(dump_file) = &opts.dump_spirt_passes { + // HACK(eddyb) using `.with_extension(...)` may replace part of a + // `.`-containing file name, but we want to always append `.html`. + let mut dump_file_html = dump_file.as_os_str().to_owned(); + dump_file_html.push(".html"); + + let plan = spirt::print::Plan::for_versions( + &cx, + per_pass_module_for_dumping + .iter() + .map(|(pass, module)| (format!("after {pass}"), module)), + ); + let pretty = plan.pretty_print(); + + // FIXME(eddyb) don't allocate whole `String`s here. + std::fs::write(dump_file, pretty.to_string()).unwrap(); + std::fs::write( + dump_file_html, + pretty + .render_to_html() + .with_dark_mode_support() + .to_html_doc(), + ) + .unwrap(); + } + + let spv_words = { + let _timer = sess.timer("spirt::Module::lift_to_spv_module_emitter"); + module.lift_to_spv_module_emitter().unwrap().words + }; + output = { + let _timer = sess.timer("parse-spv_words-from-spirt"); + let mut loader = Loader::new(); + rspirv::binary::parse_words(&spv_words, &mut loader).unwrap(); + loader.module() + }; + } + { let _timer = sess.timer("peephole_opts"); let types = peephole_opts::collect_types(&output); diff --git a/docs/src/codegen-args.md b/docs/src/codegen-args.md index 076caa1891..d0dc700025 100644 --- a/docs/src/codegen-args.md +++ b/docs/src/codegen-args.md @@ -138,3 +138,18 @@ anyway, be careful). ### `--no-structurize` Disables CFG structurization. Probably results in invalid modules. + +### `--spirt` + +Enables using the experimental [`SPIR-🇹` shader IR framework](https://github.com/EmbarkStudios/spirt) in the linker - more specifically, this: +- adds a `SPIR-V -> SPIR-🇹 -> SPIR-V` roundtrip + (future `SPIR-🇹` passes would go in the middle of this, and eventually codegen might not produce `SPIR-V` at all) +- replaces the existing structurizer with `SPIR-🇹` structurization (which is more robust and can e.g. handle `OpPhi`s) +- runs some existing `SPIR-V` legalization/optimization passes (`mem2reg`) *before* inlining, instead of *only after* (as the `OpPhi`s they would produce are no longer an issue for structurization) + +For more information, also see [the `SPIR-🇹` repository](https://github.com/EmbarkStudios/spirt). + +### `--dump-spirt-passes FILE` + +Dump the `SPIR-🇹` module across passes (i.e. all of the versions before/after each pass), as a combined report, to `FILE` and `FILE.html`. +(the `.html` version of the report is the recommended form for viewing, as it uses tabling for versions, syntax-highlighting-like styling, and use->def linking) diff --git a/tests/src/main.rs b/tests/src/main.rs index ff9eed5117..d0a30ce23e 100644 --- a/tests/src/main.rs +++ b/tests/src/main.rs @@ -27,8 +27,8 @@ struct Opt { } impl Opt { - pub fn environments(&self) -> Vec { - self.target_env.split(',').map(String::from).collect() + pub fn environments(&self) -> impl Iterator { + self.target_env.split(',') } } @@ -125,12 +125,20 @@ impl Runner { .join(" ") } - for env in self.opt.environments() { + for (env, spirt) in self + .opt + .environments() + .flat_map(|env| [(env, false), (env, true)]) + { + // HACK(eddyb) in order to allow *some* tests to have separate output + // with the SPIR-T support enabled (via `--spirt`), while keeping + // *most* of the tests unchanged, we take advantage of "stage IDs", + // which offer `// only-S` and `// ignore-S` for any stage ID `S`. + let stage_id = if spirt { "spirt" } else { "not_spirt" }; + let target = format!("{}{}", TARGET_PREFIX, env); - let mut config = compiletest::Config::default(); let libs = build_deps(&self.deps_target_dir, &self.codegen_backend_path, &target); - - let flags = test_rustc_flags( + let mut flags = test_rustc_flags( &self.codegen_backend_path, &libs, &[ @@ -142,14 +150,22 @@ impl Runner { .join(DepKind::ProcMacro.target_dir_suffix(&target)), ], ); - - config.target_rustcflags = Some(flags); - config.mode = mode.parse().expect("Invalid mode"); - config.target = target; - config.src_base = self.tests_dir.join(mode); - config.build_base = self.compiletest_build_dir.clone(); - config.bless = self.opt.bless; - config.filters = self.opt.filters.clone(); + if spirt { + flags += " -Cllvm-args=--spirt"; + } + + let config = compiletest::Config { + stage_id: stage_id.to_string(), + target_rustcflags: Some(flags), + mode: mode.parse().expect("Invalid mode"), + target, + src_base: self.tests_dir.join(mode), + build_base: self.compiletest_build_dir.clone(), + bless: self.opt.bless, + filters: self.opt.filters.clone(), + ..compiletest::Config::default() + }; + // FIXME(eddyb) do we need this? shouldn't `compiletest` be independent? config.clean_rmeta(); compiletest::run_tests(&config); diff --git a/tests/ui/arch/all_memory_barrier.rs b/tests/ui/arch/all_memory_barrier.rs index b3f6d2f374..2465d3f81b 100644 --- a/tests/ui/arch/all_memory_barrier.rs +++ b/tests/ui/arch/all_memory_barrier.rs @@ -1,3 +1,5 @@ +// normalize-stderr-not_spirt "OpLine %8 11 1" -> "OpNoLine" + // build-pass // compile-flags: -C target-feature=+VulkanMemoryModelDeviceScopeKHR,+ext:SPV_KHR_vulkan_memory_model // compile-flags: -C llvm-args=--disassemble-fn=all_memory_barrier::all_memory_barrier diff --git a/tests/ui/arch/all_memory_barrier.stderr b/tests/ui/arch/all_memory_barrier.stderr index 6be03bb8e3..99a24af571 100644 --- a/tests/ui/arch/all_memory_barrier.stderr +++ b/tests/ui/arch/all_memory_barrier.stderr @@ -2,6 +2,6 @@ %4 = OpLabel OpLine %5 75 4 OpMemoryBarrier %6 %7 -OpLine %8 9 1 +OpNoLine OpReturn OpFunctionEnd diff --git a/tests/ui/arch/all_memory_barrier_with_group_sync.rs b/tests/ui/arch/all_memory_barrier_with_group_sync.rs index dc49dffd18..c872da56b0 100644 --- a/tests/ui/arch/all_memory_barrier_with_group_sync.rs +++ b/tests/ui/arch/all_memory_barrier_with_group_sync.rs @@ -1,3 +1,5 @@ +// normalize-stderr-not_spirt "OpLine %9 11 1" -> "OpNoLine" + // build-pass // compile-flags: -C target-feature=+VulkanMemoryModelDeviceScopeKHR,+ext:SPV_KHR_vulkan_memory_model // compile-flags: -C llvm-args=--disassemble-fn=all_memory_barrier_with_group_sync::all_memory_barrier_with_group_sync diff --git a/tests/ui/arch/all_memory_barrier_with_group_sync.stderr b/tests/ui/arch/all_memory_barrier_with_group_sync.stderr index bba4823a93..ce22a314ef 100644 --- a/tests/ui/arch/all_memory_barrier_with_group_sync.stderr +++ b/tests/ui/arch/all_memory_barrier_with_group_sync.stderr @@ -2,6 +2,6 @@ %4 = OpLabel OpLine %5 41 4 OpControlBarrier %6 %7 %8 -OpLine %9 9 1 +OpNoLine OpReturn OpFunctionEnd diff --git a/tests/ui/arch/device_memory_barrier.rs b/tests/ui/arch/device_memory_barrier.rs index e43db6d777..39d44c6432 100644 --- a/tests/ui/arch/device_memory_barrier.rs +++ b/tests/ui/arch/device_memory_barrier.rs @@ -1,3 +1,5 @@ +// normalize-stderr-not_spirt "OpLine %8 11 1" -> "OpNoLine" + // build-pass // compile-flags: -C target-feature=+VulkanMemoryModelDeviceScopeKHR,+ext:SPV_KHR_vulkan_memory_model // compile-flags: -C llvm-args=--disassemble-fn=device_memory_barrier::device_memory_barrier diff --git a/tests/ui/arch/device_memory_barrier.stderr b/tests/ui/arch/device_memory_barrier.stderr index 6be03bb8e3..99a24af571 100644 --- a/tests/ui/arch/device_memory_barrier.stderr +++ b/tests/ui/arch/device_memory_barrier.stderr @@ -2,6 +2,6 @@ %4 = OpLabel OpLine %5 75 4 OpMemoryBarrier %6 %7 -OpLine %8 9 1 +OpNoLine OpReturn OpFunctionEnd diff --git a/tests/ui/arch/device_memory_barrier_with_group_sync.rs b/tests/ui/arch/device_memory_barrier_with_group_sync.rs index 294dc45870..dfb8dbfcab 100644 --- a/tests/ui/arch/device_memory_barrier_with_group_sync.rs +++ b/tests/ui/arch/device_memory_barrier_with_group_sync.rs @@ -1,3 +1,5 @@ +// normalize-stderr-not_spirt "OpLine %9 11 1" -> "OpNoLine" + // build-pass // compile-flags: -C target-feature=+VulkanMemoryModelDeviceScopeKHR,+ext:SPV_KHR_vulkan_memory_model // compile-flags: -C llvm-args=--disassemble-fn=device_memory_barrier_with_group_sync::device_memory_barrier_with_group_sync diff --git a/tests/ui/arch/device_memory_barrier_with_group_sync.stderr b/tests/ui/arch/device_memory_barrier_with_group_sync.stderr index bba4823a93..ce22a314ef 100644 --- a/tests/ui/arch/device_memory_barrier_with_group_sync.stderr +++ b/tests/ui/arch/device_memory_barrier_with_group_sync.stderr @@ -2,6 +2,6 @@ %4 = OpLabel OpLine %5 41 4 OpControlBarrier %6 %7 %8 -OpLine %9 9 1 +OpNoLine OpReturn OpFunctionEnd diff --git a/tests/ui/arch/workgroup_memory_barrier.rs b/tests/ui/arch/workgroup_memory_barrier.rs index 1a4b6de668..87fef3a040 100644 --- a/tests/ui/arch/workgroup_memory_barrier.rs +++ b/tests/ui/arch/workgroup_memory_barrier.rs @@ -1,3 +1,5 @@ +// normalize-stderr-not_spirt "OpLine %8 10 1" -> "OpNoLine" + // build-pass // compile-flags: -C llvm-args=--disassemble-fn=workgroup_memory_barrier::workgroup_memory_barrier diff --git a/tests/ui/arch/workgroup_memory_barrier.stderr b/tests/ui/arch/workgroup_memory_barrier.stderr index 30eaf51944..99a24af571 100644 --- a/tests/ui/arch/workgroup_memory_barrier.stderr +++ b/tests/ui/arch/workgroup_memory_barrier.stderr @@ -2,6 +2,6 @@ %4 = OpLabel OpLine %5 75 4 OpMemoryBarrier %6 %7 -OpLine %8 8 1 +OpNoLine OpReturn OpFunctionEnd diff --git a/tests/ui/arch/workgroup_memory_barrier_with_group_sync.rs b/tests/ui/arch/workgroup_memory_barrier_with_group_sync.rs index 125df880d6..1080c5818f 100644 --- a/tests/ui/arch/workgroup_memory_barrier_with_group_sync.rs +++ b/tests/ui/arch/workgroup_memory_barrier_with_group_sync.rs @@ -1,3 +1,5 @@ +// normalize-stderr-not_spirt "OpLine %8 10 1" -> "OpNoLine" + // build-pass // compile-flags: -C llvm-args=--disassemble-fn=workgroup_memory_barrier_with_group_sync::workgroup_memory_barrier_with_group_sync diff --git a/tests/ui/arch/workgroup_memory_barrier_with_group_sync.stderr b/tests/ui/arch/workgroup_memory_barrier_with_group_sync.stderr index 27bfbb9c74..37119b71c8 100644 --- a/tests/ui/arch/workgroup_memory_barrier_with_group_sync.stderr +++ b/tests/ui/arch/workgroup_memory_barrier_with_group_sync.stderr @@ -2,6 +2,6 @@ %4 = OpLabel OpLine %5 41 4 OpControlBarrier %6 %6 %7 -OpLine %8 8 1 +OpNoLine OpReturn OpFunctionEnd diff --git a/tests/ui/dis/add_two_ints.rs b/tests/ui/dis/add_two_ints.rs index 81dccc353d..65ccc4bf15 100644 --- a/tests/ui/dis/add_two_ints.rs +++ b/tests/ui/dis/add_two_ints.rs @@ -1,3 +1,5 @@ +// normalize-stderr-not_spirt "OpLine %7 10 1" -> "OpNoLine" + // build-pass // compile-flags: -C llvm-args=--disassemble-fn=add_two_ints::add_two_ints diff --git a/tests/ui/dis/add_two_ints.stderr b/tests/ui/dis/add_two_ints.stderr index 678a68ffc8..9b0d0e399c 100644 --- a/tests/ui/dis/add_two_ints.stderr +++ b/tests/ui/dis/add_two_ints.stderr @@ -2,8 +2,8 @@ %4 = OpFunctionParameter %2 %5 = OpFunctionParameter %2 %6 = OpLabel -OpLine %7 7 4 +OpLine %7 9 4 %8 = OpIAdd %2 %4 %5 -OpLine %7 8 1 +OpNoLine OpReturnValue %8 OpFunctionEnd diff --git a/tests/ui/dis/asm.rs b/tests/ui/dis/asm.rs index 1e2a5a6f01..74c57fc12b 100644 --- a/tests/ui/dis/asm.rs +++ b/tests/ui/dis/asm.rs @@ -1,3 +1,5 @@ +// normalize-stderr-not_spirt "OpLine %5 18 1" -> "OpNoLine" + // build-pass // compile-flags: -C llvm-args=--disassemble-fn=asm::asm diff --git a/tests/ui/dis/asm.stderr b/tests/ui/dis/asm.stderr index c61508e135..55e3328c0a 100644 --- a/tests/ui/dis/asm.stderr +++ b/tests/ui/dis/asm.stderr @@ -1,7 +1,7 @@ %1 = OpFunction %2 None %3 %4 = OpLabel -OpLine %5 9 8 +OpLine %5 11 8 OpMemoryBarrier %6 %7 -OpLine %5 16 1 +OpNoLine OpReturn OpFunctionEnd diff --git a/tests/ui/dis/asm_add_two_ints.rs b/tests/ui/dis/asm_add_two_ints.rs index e7cbedf191..5cf3a03816 100644 --- a/tests/ui/dis/asm_add_two_ints.rs +++ b/tests/ui/dis/asm_add_two_ints.rs @@ -1,3 +1,5 @@ +// normalize-stderr-not_spirt "OpLine %7 20 1" -> "OpNoLine" + // build-pass // compile-flags: -C llvm-args=--disassemble-fn=asm_add_two_ints::add_two_ints diff --git a/tests/ui/dis/asm_add_two_ints.stderr b/tests/ui/dis/asm_add_two_ints.stderr index 3bf27dbbc1..a25cc33c01 100644 --- a/tests/ui/dis/asm_add_two_ints.stderr +++ b/tests/ui/dis/asm_add_two_ints.stderr @@ -2,8 +2,8 @@ %4 = OpFunctionParameter %2 %5 = OpFunctionParameter %2 %6 = OpLabel -OpLine %7 10 8 +OpLine %7 12 8 %8 = OpIAdd %2 %4 %5 -OpLine %7 18 1 +OpNoLine OpReturnValue %8 OpFunctionEnd diff --git a/tests/ui/dis/asm_op_decorate.rs b/tests/ui/dis/asm_op_decorate.not_spirt.rs similarity index 94% rename from tests/ui/dis/asm_op_decorate.rs rename to tests/ui/dis/asm_op_decorate.not_spirt.rs index 68881a2d34..01d1a08d6f 100644 --- a/tests/ui/dis/asm_op_decorate.rs +++ b/tests/ui/dis/asm_op_decorate.not_spirt.rs @@ -1,3 +1,6 @@ +// HACK(eddyb) duplicate of asm_op_decorate.spirt.rs because only-/ignore- do not work with revisions. +// only-not_spirt + // build-pass // compile-flags: -C target-feature=+RuntimeDescriptorArray,+ext:SPV_EXT_descriptor_indexing // compile-flags: -C llvm-args=--disassemble-globals diff --git a/tests/ui/dis/asm_op_decorate.not_spirt.stderr b/tests/ui/dis/asm_op_decorate.not_spirt.stderr new file mode 100644 index 0000000000..467694686f --- /dev/null +++ b/tests/ui/dis/asm_op_decorate.not_spirt.stderr @@ -0,0 +1,4 @@ +error: invalid character `'.'` in crate name: `asm_op_decorate.not_spirt` + +error: aborting due to previous error + diff --git a/tests/ui/dis/asm_op_decorate.spirt.rs b/tests/ui/dis/asm_op_decorate.spirt.rs new file mode 100644 index 0000000000..67a90fd0aa --- /dev/null +++ b/tests/ui/dis/asm_op_decorate.spirt.rs @@ -0,0 +1,48 @@ +// HACK(eddyb) duplicate of asm_op_decorate.not_spirt.rs because only-/ignore- do not work with revisions. +// only-spirt + +// build-pass +// compile-flags: -C target-feature=+RuntimeDescriptorArray,+ext:SPV_EXT_descriptor_indexing +// compile-flags: -C llvm-args=--disassemble-globals +// normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" +// normalize-stderr-test "OpExtension .SPV_KHR_vulkan_memory_model.\n" -> "" +// normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" + +// FIXME(eddyb) this should use revisions to track both the `vulkan1.2` output +// and the pre-`vulkan1.2` output, but per-revisions `{only,ignore}-*` directives +// are not supported in `compiletest-rs`. +// ignore-vulkan1.2 + +use core::arch::asm; +use spirv_std::spirv; + +fn add_decorate() { + unsafe { + let offset = 1u32; + asm!( + "OpDecorate %image_2d_var DescriptorSet 0", + "OpDecorate %image_2d_var Binding 0", + "%uint = OpTypeInt 32 0", + "%float = OpTypeFloat 32", + "%uint_0 = OpConstant %uint 0", + "%image_2d = OpTypeImage %float Dim2D 0 0 0 1 Unknown", + "%sampled_image_2d = OpTypeSampledImage %image_2d", + "%image_array = OpTypeRuntimeArray %sampled_image_2d", + // NOTE(eddyb) `Generic` is used here because it's the placeholder + // for storage class inference - both of the two `OpTypePointer` + // types below should end up inferring to `UniformConstant`. + "%ptr_image_array = OpTypePointer Generic %image_array", + "%image_2d_var = OpVariable %ptr_image_array UniformConstant", + "%ptr_sampled_image_2d = OpTypePointer Generic %sampled_image_2d", + "", // ^^ type preamble + "%offset = OpLoad _ {0}", + "%24 = OpAccessChain %ptr_sampled_image_2d %image_2d_var %offset", + "%25 = OpLoad %sampled_image_2d %24", + in(reg) &offset, + ); + } +} +#[spirv(fragment)] +pub fn main() { + add_decorate(); +} diff --git a/tests/ui/dis/asm_op_decorate.spirt.stderr b/tests/ui/dis/asm_op_decorate.spirt.stderr new file mode 100644 index 0000000000..f35f846d7b --- /dev/null +++ b/tests/ui/dis/asm_op_decorate.spirt.stderr @@ -0,0 +1,4 @@ +error: invalid character `'.'` in crate name: `asm_op_decorate.spirt` + +error: aborting due to previous error + diff --git a/tests/ui/dis/asm_op_decorate.stderr b/tests/ui/dis/asm_op_decorate.stderr deleted file mode 100644 index 2f7f60b8f2..0000000000 --- a/tests/ui/dis/asm_op_decorate.stderr +++ /dev/null @@ -1,29 +0,0 @@ -OpCapability Float64 -OpCapability Int16 -OpCapability Int64 -OpCapability Int8 -OpCapability RuntimeDescriptorArray -OpCapability ShaderClockKHR -OpCapability Shader -OpExtension "SPV_EXT_descriptor_indexing" -OpExtension "SPV_KHR_shader_clock" -OpMemoryModel Logical Simple -OpEntryPoint Fragment %1 "main" -OpExecutionMode %1 OriginUpperLeft -%2 = OpString "$OPSTRING_FILENAME/asm_op_decorate.rs" -OpName %3 "asm_op_decorate::add_decorate" -OpName %4 "asm_op_decorate::main" -OpDecorate %5 ArrayStride 4 -OpDecorate %6 DescriptorSet 0 -OpDecorate %6 Binding 0 -%7 = OpTypeVoid -%8 = OpTypeFunction %7 -%9 = OpTypeInt 32 0 -%10 = OpConstant %9 1 -%11 = OpTypeFloat 32 -%12 = OpTypeImage %11 2D 0 0 0 1 Unknown -%13 = OpTypeSampledImage %12 -%5 = OpTypeRuntimeArray %13 -%14 = OpTypePointer UniformConstant %5 -%6 = OpVariable %14 UniformConstant -%15 = OpTypePointer UniformConstant %13 diff --git a/tests/ui/dis/complex_image_sample_inst.rs b/tests/ui/dis/complex_image_sample_inst.rs index f42cce8d0b..8890f0e435 100644 --- a/tests/ui/dis/complex_image_sample_inst.rs +++ b/tests/ui/dis/complex_image_sample_inst.rs @@ -1,3 +1,5 @@ +// normalize-stderr-not_spirt "OpLine %12 60 1" -> "OpNoLine" + // build-pass // compile-flags: -Ctarget-feature=+RuntimeDescriptorArray,+ext:SPV_EXT_descriptor_indexing // compile-flags: -C llvm-args=--disassemble-fn=complex_image_sample_inst::sample_proj_lod diff --git a/tests/ui/dis/complex_image_sample_inst.stderr b/tests/ui/dis/complex_image_sample_inst.stderr index 9994e1706a..621b897961 100644 --- a/tests/ui/dis/complex_image_sample_inst.stderr +++ b/tests/ui/dis/complex_image_sample_inst.stderr @@ -5,10 +5,10 @@ %8 = OpFunctionParameter %9 %10 = OpFunctionParameter %9 %11 = OpLabel -OpLine %12 18 8 +OpLine %12 20 8 %13 = OpAccessChain %14 %15 %16 %17 = OpLoad %18 %13 %19 = OpImageSampleProjExplicitLod %2 %17 %4 Grad|ConstOffset %5 %7 %20 -OpLine %12 58 1 +OpNoLine OpReturnValue %19 OpFunctionEnd diff --git a/tests/ui/dis/custom_entry_point.rs b/tests/ui/dis/custom_entry_point.not_spirt.rs similarity index 75% rename from tests/ui/dis/custom_entry_point.rs rename to tests/ui/dis/custom_entry_point.not_spirt.rs index 2121c3146d..a2c928af1a 100644 --- a/tests/ui/dis/custom_entry_point.rs +++ b/tests/ui/dis/custom_entry_point.not_spirt.rs @@ -1,3 +1,6 @@ +// HACK(eddyb) duplicate of custom_entry_point.spirt.rs because only-/ignore- do not work with revisions. +// only-not_spirt + // build-pass // compile-flags: -C llvm-args=--disassemble-globals // normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" diff --git a/tests/ui/dis/custom_entry_point.not_spirt.stderr b/tests/ui/dis/custom_entry_point.not_spirt.stderr new file mode 100644 index 0000000000..3190a4d226 --- /dev/null +++ b/tests/ui/dis/custom_entry_point.not_spirt.stderr @@ -0,0 +1,4 @@ +error: invalid character `'.'` in crate name: `custom_entry_point.not_spirt` + +error: aborting due to previous error + diff --git a/tests/ui/dis/custom_entry_point.spirt.rs b/tests/ui/dis/custom_entry_point.spirt.rs new file mode 100644 index 0000000000..3db0be47a1 --- /dev/null +++ b/tests/ui/dis/custom_entry_point.spirt.rs @@ -0,0 +1,13 @@ +// HACK(eddyb) duplicate of custom_entry_point.not_spirt.rs because only-/ignore- do not work with revisions. +// only-spirt + +// build-pass +// compile-flags: -C llvm-args=--disassemble-globals +// normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" +// normalize-stderr-test "OpExtension .SPV_KHR_vulkan_memory_model.\n" -> "" +// normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" + +use spirv_std::spirv; + +#[spirv(fragment(entry_point_name = "hello_world"))] +pub fn main() {} diff --git a/tests/ui/dis/custom_entry_point.spirt.stderr b/tests/ui/dis/custom_entry_point.spirt.stderr new file mode 100644 index 0000000000..22c5c345f9 --- /dev/null +++ b/tests/ui/dis/custom_entry_point.spirt.stderr @@ -0,0 +1,4 @@ +error: invalid character `'.'` in crate name: `custom_entry_point.spirt` + +error: aborting due to previous error + diff --git a/tests/ui/dis/custom_entry_point.stderr b/tests/ui/dis/custom_entry_point.stderr deleted file mode 100644 index 2881a9b4e5..0000000000 --- a/tests/ui/dis/custom_entry_point.stderr +++ /dev/null @@ -1,14 +0,0 @@ -OpCapability Float64 -OpCapability Int16 -OpCapability Int64 -OpCapability Int8 -OpCapability ShaderClockKHR -OpCapability Shader -OpExtension "SPV_KHR_shader_clock" -OpMemoryModel Logical Simple -OpEntryPoint Fragment %1 "hello_world" -OpExecutionMode %1 OriginUpperLeft -%2 = OpString "$OPSTRING_FILENAME/custom_entry_point.rs" -OpName %3 "custom_entry_point::main" -%4 = OpTypeVoid -%5 = OpTypeFunction %4 diff --git a/tests/ui/dis/entry-pass-mode-cast-array.rs b/tests/ui/dis/entry-pass-mode-cast-array.rs index 0e1314465e..105594f9ac 100644 --- a/tests/ui/dis/entry-pass-mode-cast-array.rs +++ b/tests/ui/dis/entry-pass-mode-cast-array.rs @@ -1,3 +1,5 @@ +// normalize-stderr-not_spirt "OpLine %5 18 1" -> "OpNoLine" + // This is a similar setup to the `issue-731` test, but instead of "just" the // missing copy out of the global (`Input`) `OpVariable`, small enough types // would fail much earlier (by generating unsupported pointer casts). diff --git a/tests/ui/dis/entry-pass-mode-cast-array.stderr b/tests/ui/dis/entry-pass-mode-cast-array.stderr index 903414df87..bc4c2f2c59 100644 --- a/tests/ui/dis/entry-pass-mode-cast-array.stderr +++ b/tests/ui/dis/entry-pass-mode-cast-array.stderr @@ -1,13 +1,13 @@ %1 = OpFunction %2 None %3 %4 = OpLabel -OpLine %5 13 12 +OpLine %5 15 12 %6 = OpLoad %7 %8 -OpLine %5 14 4 +OpLine %5 16 4 %9 = OpCompositeExtract %10 %6 0 %11 = OpFAdd %10 %9 %12 %13 = OpCompositeInsert %7 %11 %6 0 -OpLine %5 15 4 +OpLine %5 17 4 OpStore %14 %13 -OpLine %5 16 1 +OpNoLine OpReturn OpFunctionEnd diff --git a/tests/ui/dis/generic-fn-op-name.rs b/tests/ui/dis/generic-fn-op-name.not_spirt.rs similarity index 83% rename from tests/ui/dis/generic-fn-op-name.rs rename to tests/ui/dis/generic-fn-op-name.not_spirt.rs index 844a8a3ebc..3127e2bb33 100644 --- a/tests/ui/dis/generic-fn-op-name.rs +++ b/tests/ui/dis/generic-fn-op-name.not_spirt.rs @@ -1,3 +1,6 @@ +// HACK(eddyb) duplicate of generic-fn-op-name.spirt.rs because only-/ignore- do not work with revisions. +// only-not_spirt + // Test that generic functions' `OpName` correctly include generic arguments. // build-pass diff --git a/tests/ui/dis/generic-fn-op-name.not_spirt.stderr b/tests/ui/dis/generic-fn-op-name.not_spirt.stderr new file mode 100644 index 0000000000..daf92f71b4 --- /dev/null +++ b/tests/ui/dis/generic-fn-op-name.not_spirt.stderr @@ -0,0 +1,4 @@ +error: invalid character `'.'` in crate name: `generic_fn_op_name.not_spirt` + +error: aborting due to previous error + diff --git a/tests/ui/dis/generic-fn-op-name.spirt.rs b/tests/ui/dis/generic-fn-op-name.spirt.rs new file mode 100644 index 0000000000..86da4f6dad --- /dev/null +++ b/tests/ui/dis/generic-fn-op-name.spirt.rs @@ -0,0 +1,23 @@ +// HACK(eddyb) duplicate of generic-fn-op-name.not_spirt.rs because only-/ignore- do not work with revisions. +// only-spirt + +// Test that generic functions' `OpName` correctly include generic arguments. + +// build-pass +// compile-flags: -C llvm-args=--disassemble-globals +// normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" +// normalize-stderr-test "OpExtension .SPV_KHR_vulkan_memory_model.\n" -> "" +// normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" + +#![feature(adt_const_params)] +#![allow(incomplete_features)] + +use spirv_std::image::Dimensionality; +use spirv_std::spirv; + +fn generic() {} + +#[spirv(fragment)] +pub fn main() { + generic::(); +} diff --git a/tests/ui/dis/generic-fn-op-name.spirt.stderr b/tests/ui/dis/generic-fn-op-name.spirt.stderr new file mode 100644 index 0000000000..d8c181076c --- /dev/null +++ b/tests/ui/dis/generic-fn-op-name.spirt.stderr @@ -0,0 +1,4 @@ +error: invalid character `'.'` in crate name: `generic_fn_op_name.spirt` + +error: aborting due to previous error + diff --git a/tests/ui/dis/generic-fn-op-name.stderr b/tests/ui/dis/generic-fn-op-name.stderr deleted file mode 100644 index 53e5b57536..0000000000 --- a/tests/ui/dis/generic-fn-op-name.stderr +++ /dev/null @@ -1,15 +0,0 @@ -OpCapability Float64 -OpCapability Int16 -OpCapability Int64 -OpCapability Int8 -OpCapability ShaderClockKHR -OpCapability Shader -OpExtension "SPV_KHR_shader_clock" -OpMemoryModel Logical Simple -OpEntryPoint Fragment %1 "main" -OpExecutionMode %1 OriginUpperLeft -%2 = OpString "$OPSTRING_FILENAME/generic-fn-op-name.rs" -OpName %3 "generic_fn_op_name::generic::" -OpName %4 "generic_fn_op_name::main" -%5 = OpTypeVoid -%6 = OpTypeFunction %5 diff --git a/tests/ui/dis/index_user_dst.rs b/tests/ui/dis/index_user_dst.not_spirt.rs similarity index 67% rename from tests/ui/dis/index_user_dst.rs rename to tests/ui/dis/index_user_dst.not_spirt.rs index da7df03676..ac53dc2db5 100644 --- a/tests/ui/dis/index_user_dst.rs +++ b/tests/ui/dis/index_user_dst.not_spirt.rs @@ -1,3 +1,6 @@ +// HACK(eddyb) duplicate of index_user_dst.spirt.rs because only-/ignore- do not work with revisions. +// only-not_spirt + // build-pass // compile-flags: -C llvm-args=--disassemble-entry=main diff --git a/tests/ui/dis/index_user_dst.not_spirt.stderr b/tests/ui/dis/index_user_dst.not_spirt.stderr new file mode 100644 index 0000000000..f1ff2c5290 --- /dev/null +++ b/tests/ui/dis/index_user_dst.not_spirt.stderr @@ -0,0 +1,4 @@ +error: invalid character `'.'` in crate name: `index_user_dst.not_spirt` + +error: aborting due to previous error + diff --git a/tests/ui/dis/index_user_dst.spirt.rs b/tests/ui/dis/index_user_dst.spirt.rs new file mode 100644 index 0000000000..ba7611923a --- /dev/null +++ b/tests/ui/dis/index_user_dst.spirt.rs @@ -0,0 +1,13 @@ +// HACK(eddyb) duplicate of index_user_dst.not_spirt.rs because only-/ignore- do not work with revisions. +// only-spirt + +// build-pass +// compile-flags: -C llvm-args=--disassemble-entry=main + +use spirv_std::spirv; + +#[spirv(fragment)] +pub fn main(#[spirv(storage_buffer, descriptor_set = 0, binding = 0)] slice: &mut [f32]) { + let float: f32 = slice[0]; + let _ = float; +} diff --git a/tests/ui/dis/index_user_dst.spirt.stderr b/tests/ui/dis/index_user_dst.spirt.stderr new file mode 100644 index 0000000000..62de16de6f --- /dev/null +++ b/tests/ui/dis/index_user_dst.spirt.stderr @@ -0,0 +1,4 @@ +error: invalid character `'.'` in crate name: `index_user_dst.spirt` + +error: aborting due to previous error + diff --git a/tests/ui/dis/index_user_dst.stderr b/tests/ui/dis/index_user_dst.stderr deleted file mode 100644 index 540de9f32b..0000000000 --- a/tests/ui/dis/index_user_dst.stderr +++ /dev/null @@ -1,34 +0,0 @@ -%1 = OpFunction %2 None %3 -%4 = OpLabel -OpLine %5 7 12 -%6 = OpAccessChain %7 %8 %9 -%10 = OpArrayLength %11 %8 0 -OpLine %5 8 21 -%12 = OpULessThan %13 %9 %10 -OpLine %5 8 21 -OpSelectionMerge %14 None -OpBranchConditional %12 %15 %16 -%15 = OpLabel -OpLine %5 8 21 -%17 = OpInBoundsAccessChain %18 %6 %9 -%19 = OpLoad %20 %17 -OpLine %5 10 1 -OpReturn -%16 = OpLabel -OpLine %5 8 21 -OpBranch %21 -%21 = OpLabel -OpBranch %22 -%22 = OpLabel -%23 = OpPhi %13 %24 %21 %24 %25 -OpLoopMerge %26 %25 None -OpBranchConditional %23 %27 %26 -%27 = OpLabel -OpBranch %25 -%25 = OpLabel -OpBranch %22 -%26 = OpLabel -OpUnreachable -%14 = OpLabel -OpUnreachable -OpFunctionEnd diff --git a/tests/ui/dis/issue-373.rs b/tests/ui/dis/issue-373.not_spirt.rs similarity index 81% rename from tests/ui/dis/issue-373.rs rename to tests/ui/dis/issue-373.not_spirt.rs index 20f749b66d..4423d1e840 100644 --- a/tests/ui/dis/issue-373.rs +++ b/tests/ui/dis/issue-373.not_spirt.rs @@ -1,3 +1,6 @@ +// HACK(eddyb) duplicate of issue-373.spirt.rs because only-/ignore- do not work with revisions. +// only-not_spirt + // Test that returning a single-scalar-field `#[repr(C)] struct` doesn't generate // unsupported pointer casts (the problem was the use of `PassMode::Cast`, through // the default Rust ABI adjustments, that we now override through query hooks). diff --git a/tests/ui/dis/issue-373.not_spirt.stderr b/tests/ui/dis/issue-373.not_spirt.stderr new file mode 100644 index 0000000000..0c806725d3 --- /dev/null +++ b/tests/ui/dis/issue-373.not_spirt.stderr @@ -0,0 +1,4 @@ +error: invalid character `'.'` in crate name: `issue_373.not_spirt` + +error: aborting due to previous error + diff --git a/tests/ui/dis/issue-373.spirt.rs b/tests/ui/dis/issue-373.spirt.rs new file mode 100644 index 0000000000..76664edc2f --- /dev/null +++ b/tests/ui/dis/issue-373.spirt.rs @@ -0,0 +1,26 @@ +// HACK(eddyb) duplicate of issue-373.not_spirt.rs because only-/ignore- do not work with revisions. +// only-spirt + +// Test that returning a single-scalar-field `#[repr(C)] struct` doesn't generate +// unsupported pointer casts (the problem was the use of `PassMode::Cast`, through +// the default Rust ABI adjustments, that we now override through query hooks). + +// build-pass +// compile-flags: -C llvm-args=--disassemble-entry=main + +use spirv_std::spirv; + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct S { + x: f32, +} + +fn f() -> S { + S { x: 2.0 } +} + +#[spirv(fragment)] +pub fn main(out: &mut f32) { + *out = f().x; +} diff --git a/tests/ui/dis/issue-373.spirt.stderr b/tests/ui/dis/issue-373.spirt.stderr new file mode 100644 index 0000000000..ff6adcd19b --- /dev/null +++ b/tests/ui/dis/issue-373.spirt.stderr @@ -0,0 +1,4 @@ +error: invalid character `'.'` in crate name: `issue_373.spirt` + +error: aborting due to previous error + diff --git a/tests/ui/dis/issue-373.stderr b/tests/ui/dis/issue-373.stderr deleted file mode 100644 index ab8e636257..0000000000 --- a/tests/ui/dis/issue-373.stderr +++ /dev/null @@ -1,11 +0,0 @@ -%1 = OpFunction %2 None %3 -%4 = OpLabel -OpLine %5 22 11 -%6 = OpFunctionCall %7 %8 -OpLine %5 22 11 -%9 = OpCompositeExtract %10 %6 0 -OpLine %5 22 4 -OpStore %11 %9 -OpLine %5 23 1 -OpReturn -OpFunctionEnd diff --git a/tests/ui/dis/issue-723-output.rs b/tests/ui/dis/issue-723-output.not_spirt.rs similarity index 90% rename from tests/ui/dis/issue-723-output.rs rename to tests/ui/dis/issue-723-output.not_spirt.rs index 9afa48e202..a8edc96ad5 100644 --- a/tests/ui/dis/issue-723-output.rs +++ b/tests/ui/dis/issue-723-output.not_spirt.rs @@ -1,3 +1,6 @@ +// HACK(eddyb) duplicate of issue-723-output.spirt.rs because only-/ignore- do not work with revisions. +// only-not_spirt + // Test that interface (global) `OpVariable`s mentioned by `OpEntryPoint` don't // have to be used by the shader, for storage class inference to succeed. diff --git a/tests/ui/dis/issue-723-output.not_spirt.stderr b/tests/ui/dis/issue-723-output.not_spirt.stderr new file mode 100644 index 0000000000..32358b579e --- /dev/null +++ b/tests/ui/dis/issue-723-output.not_spirt.stderr @@ -0,0 +1,4 @@ +error: invalid character `'.'` in crate name: `issue_723_output.not_spirt` + +error: aborting due to previous error + diff --git a/tests/ui/dis/issue-723-output.spirt.rs b/tests/ui/dis/issue-723-output.spirt.rs new file mode 100644 index 0000000000..435fd7e858 --- /dev/null +++ b/tests/ui/dis/issue-723-output.spirt.rs @@ -0,0 +1,25 @@ +// HACK(eddyb) duplicate of issue-723-output.not_spirt.rs because only-/ignore- do not work with revisions. +// only-spirt + +// Test that interface (global) `OpVariable`s mentioned by `OpEntryPoint` don't +// have to be used by the shader, for storage class inference to succeed. + +// NOTE(eddyb) this relies on two subtleties (in order to fail without the fix): +// * disabling debuginfo (to prevent `%x.dbg.spill` stack slot generation) +// * this could be alleviated in the future if we clean up how debuginfo +// is handled in `rustc_codegen_ssa`, to not assume LLVM limitations +// * it probably needs to stay like this, to ensure the parameter is unused +// * `Output`s being handled with `&mut`, instead of by-value returns +// * if this changes, this test will likely need >=1.4 SPIR-V, which supports +// all interface `OpVariables` in `OpEntryPoint`, not just `Input`/`Output` + +// build-pass +// compile-flags: -C debuginfo=0 -C llvm-args=--disassemble-globals +// normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" +// normalize-stderr-test "OpExtension .SPV_KHR_vulkan_memory_model.\n" -> "" +// normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" + +use spirv_std::spirv; + +#[spirv(fragment)] +pub fn main(/* unused Output */ _: &mut glam::Vec4) {} diff --git a/tests/ui/dis/issue-723-output.spirt.stderr b/tests/ui/dis/issue-723-output.spirt.stderr new file mode 100644 index 0000000000..36cfc9ea8e --- /dev/null +++ b/tests/ui/dis/issue-723-output.spirt.stderr @@ -0,0 +1,4 @@ +error: invalid character `'.'` in crate name: `issue_723_output.spirt` + +error: aborting due to previous error + diff --git a/tests/ui/dis/issue-723-output.stderr b/tests/ui/dis/issue-723-output.stderr deleted file mode 100644 index f1783caaf8..0000000000 --- a/tests/ui/dis/issue-723-output.stderr +++ /dev/null @@ -1,19 +0,0 @@ -OpCapability Float64 -OpCapability Int16 -OpCapability Int64 -OpCapability Int8 -OpCapability ShaderClockKHR -OpCapability Shader -OpExtension "SPV_KHR_shader_clock" -OpMemoryModel Logical Simple -OpEntryPoint Fragment %1 "main" %2 -OpExecutionMode %1 OriginUpperLeft -%3 = OpString "$OPSTRING_FILENAME/issue-723-output.rs" -OpName %4 "issue_723_output::main" -OpDecorate %2 Location 0 -%5 = OpTypeVoid -%6 = OpTypeFloat 32 -%7 = OpTypeVector %6 4 -%8 = OpTypePointer Output %7 -%9 = OpTypeFunction %5 -%2 = OpVariable %8 Output diff --git a/tests/ui/dis/issue-731.rs b/tests/ui/dis/issue-731.rs index ccd8d39ef4..6c1644e76d 100644 --- a/tests/ui/dis/issue-731.rs +++ b/tests/ui/dis/issue-731.rs @@ -1,3 +1,5 @@ +// normalize-stderr-not_spirt "OpLine %5 16 1" -> "OpNoLine" + // Test that non-immediate (i.e. not one of scalar/scalar-pair/vector) inputs // get properly copied out of the global (`Input`) `OpVariable` and mutation is // only ever done on `fn`-local `OpVariable`s, not on the original global. diff --git a/tests/ui/dis/issue-731.stderr b/tests/ui/dis/issue-731.stderr index 2a34bdd5f5..5fd5cdd459 100644 --- a/tests/ui/dis/issue-731.stderr +++ b/tests/ui/dis/issue-731.stderr @@ -1,13 +1,13 @@ %1 = OpFunction %2 None %3 %4 = OpLabel -OpLine %5 11 12 +OpLine %5 13 12 %6 = OpLoad %7 %8 -OpLine %5 12 4 +OpLine %5 14 4 %9 = OpCompositeExtract %10 %6 0 %11 = OpFAdd %10 %9 %12 %13 = OpCompositeInsert %7 %11 %6 0 -OpLine %5 13 4 +OpLine %5 15 4 OpStore %14 %13 -OpLine %5 14 1 +OpNoLine OpReturn OpFunctionEnd diff --git a/tests/ui/dis/pass-mode-cast-struct.rs b/tests/ui/dis/pass-mode-cast-struct.not_spirt.rs similarity index 85% rename from tests/ui/dis/pass-mode-cast-struct.rs rename to tests/ui/dis/pass-mode-cast-struct.not_spirt.rs index c86e170d49..23215ca0a4 100644 --- a/tests/ui/dis/pass-mode-cast-struct.rs +++ b/tests/ui/dis/pass-mode-cast-struct.not_spirt.rs @@ -1,3 +1,6 @@ +// HACK(eddyb) duplicate of pass-mode-cast-struct.spirt.rs because only-/ignore- do not work with revisions. +// only-not_spirt + // Test that a small enough `struct` doesn't generate unsupported pointer casts. // (Just like `issue-373`, the problem was the use of `PassMode::Cast`, through // the default Rust ABI adjustments, that we now override through query hooks) diff --git a/tests/ui/dis/pass-mode-cast-struct.not_spirt.stderr b/tests/ui/dis/pass-mode-cast-struct.not_spirt.stderr new file mode 100644 index 0000000000..9f9dd9ab8d --- /dev/null +++ b/tests/ui/dis/pass-mode-cast-struct.not_spirt.stderr @@ -0,0 +1,4 @@ +error: invalid character `'.'` in crate name: `pass_mode_cast_struct.not_spirt` + +error: aborting due to previous error + diff --git a/tests/ui/dis/pass-mode-cast-struct.spirt.rs b/tests/ui/dis/pass-mode-cast-struct.spirt.rs new file mode 100644 index 0000000000..401427664e --- /dev/null +++ b/tests/ui/dis/pass-mode-cast-struct.spirt.rs @@ -0,0 +1,33 @@ +// HACK(eddyb) duplicate of pass-mode-cast-struct.not_spirt.rs because only-/ignore- do not work with revisions. +// only-spirt + +// Test that a small enough `struct` doesn't generate unsupported pointer casts. +// (Just like `issue-373`, the problem was the use of `PassMode::Cast`, through +// the default Rust ABI adjustments, that we now override through query hooks) + +// build-pass +// compile-flags: -C llvm-args=--disassemble-entry=main + +use spirv_std::spirv; + +struct Foo { + a: u32, + b: u8, + c: u8, +} + +impl Foo { + fn unpack(data: u64) -> Self { + Self { + a: (data >> 16 & 0xffffff) as u32, + b: (data & 0xff >> 8) as u8, + c: (data & 0xff) as u8, + } + } +} + +#[spirv(fragment)] +pub fn main(#[spirv(flat)] in_packed: u64, out_sum: &mut u32) { + let foo = Foo::unpack(in_packed); + *out_sum = foo.a + (foo.b + foo.c) as u32; +} diff --git a/tests/ui/dis/pass-mode-cast-struct.spirt.stderr b/tests/ui/dis/pass-mode-cast-struct.spirt.stderr new file mode 100644 index 0000000000..f00fab6dc2 --- /dev/null +++ b/tests/ui/dis/pass-mode-cast-struct.spirt.stderr @@ -0,0 +1,4 @@ +error: invalid character `'.'` in crate name: `pass_mode_cast_struct.spirt` + +error: aborting due to previous error + diff --git a/tests/ui/dis/pass-mode-cast-struct.stderr b/tests/ui/dis/pass-mode-cast-struct.stderr deleted file mode 100644 index 5c44a83105..0000000000 --- a/tests/ui/dis/pass-mode-cast-struct.stderr +++ /dev/null @@ -1,22 +0,0 @@ -%1 = OpFunction %2 None %3 -%4 = OpLabel -OpLine %5 27 12 -%6 = OpLoad %7 %8 -OpLine %5 28 14 -%9 = OpFunctionCall %10 %11 %6 -OpLine %5 29 15 -%12 = OpCompositeExtract %13 %9 0 -OpLine %5 29 24 -%14 = OpCompositeExtract %15 %9 1 -OpLine %5 29 32 -%16 = OpCompositeExtract %15 %9 2 -OpLine %5 29 23 -%17 = OpIAdd %15 %14 %16 -OpLine %5 29 23 -%18 = OpUConvert %13 %17 -OpLine %5 29 4 -%19 = OpIAdd %13 %12 %18 -OpStore %20 %19 -OpLine %5 30 1 -OpReturn -OpFunctionEnd diff --git a/tests/ui/dis/ptr_copy.rs b/tests/ui/dis/ptr_copy.rs index f3e692fb16..b14658388b 100644 --- a/tests/ui/dis/ptr_copy.rs +++ b/tests/ui/dis/ptr_copy.rs @@ -1,7 +1,9 @@ +// normalize-stderr-not_spirt "OpLine %8 32 1" -> "OpNoLine" + // revisions: normal via_intrinsic -// [normal] build-fail +//[normal] build-fail // normalize-stderr-test "\S*/library/core/src/" -> "$$CORE_SRC/" -// [via_intrinsic] build-pass +//[via_intrinsic] build-pass // compile-flags: -C llvm-args=--disassemble-fn=ptr_copy::copy_via_raw_ptr #![cfg_attr(via_intrinsic, feature(intrinsics))] diff --git a/tests/ui/dis/ptr_copy.via_intrinsic.stderr b/tests/ui/dis/ptr_copy.via_intrinsic.stderr index 853cc30a95..4935551402 100644 --- a/tests/ui/dis/ptr_copy.via_intrinsic.stderr +++ b/tests/ui/dis/ptr_copy.via_intrinsic.stderr @@ -2,8 +2,8 @@ %4 = OpFunctionParameter %5 %6 = OpFunctionParameter %5 %7 = OpLabel -OpLine %8 17 17 +OpLine %8 19 17 OpCopyMemory %6 %4 -OpLine %8 30 1 +OpNoLine OpReturn OpFunctionEnd diff --git a/tests/ui/dis/ptr_read.rs b/tests/ui/dis/ptr_read.rs index 494bcdb3fa..d57aec24c4 100644 --- a/tests/ui/dis/ptr_read.rs +++ b/tests/ui/dis/ptr_read.rs @@ -1,3 +1,5 @@ +// normalize-stderr-not_spirt "OpLine %11 10 1" -> "OpNoLine" + // build-pass // compile-flags: -C llvm-args=--disassemble-fn=ptr_read::copy_via_raw_ptr diff --git a/tests/ui/dis/ptr_read.stderr b/tests/ui/dis/ptr_read.stderr index c20975c585..52ea32090f 100644 --- a/tests/ui/dis/ptr_read.stderr +++ b/tests/ui/dis/ptr_read.stderr @@ -4,8 +4,8 @@ %7 = OpLabel OpLine %8 1139 8 %9 = OpLoad %10 %4 -OpLine %11 7 13 +OpLine %11 9 13 OpStore %6 %9 -OpLine %11 8 1 +OpNoLine OpReturn OpFunctionEnd diff --git a/tests/ui/dis/ptr_read_method.rs b/tests/ui/dis/ptr_read_method.rs index 41620e9ebb..c7ab7d4082 100644 --- a/tests/ui/dis/ptr_read_method.rs +++ b/tests/ui/dis/ptr_read_method.rs @@ -1,3 +1,5 @@ +// normalize-stderr-not_spirt "OpLine %11 10 1" -> "OpNoLine" + // build-pass // compile-flags: -C llvm-args=--disassemble-fn=ptr_read_method::copy_via_raw_ptr diff --git a/tests/ui/dis/ptr_read_method.stderr b/tests/ui/dis/ptr_read_method.stderr index c20975c585..52ea32090f 100644 --- a/tests/ui/dis/ptr_read_method.stderr +++ b/tests/ui/dis/ptr_read_method.stderr @@ -4,8 +4,8 @@ %7 = OpLabel OpLine %8 1139 8 %9 = OpLoad %10 %4 -OpLine %11 7 13 +OpLine %11 9 13 OpStore %6 %9 -OpLine %11 8 1 +OpNoLine OpReturn OpFunctionEnd diff --git a/tests/ui/dis/ptr_write.rs b/tests/ui/dis/ptr_write.rs index fcfdc4cd8d..080fc87344 100644 --- a/tests/ui/dis/ptr_write.rs +++ b/tests/ui/dis/ptr_write.rs @@ -1,3 +1,5 @@ +// normalize-stderr-not_spirt "OpLine %8 10 1" -> "OpNoLine" + // build-pass // compile-flags: -C llvm-args=--disassemble-fn=ptr_write::copy_via_raw_ptr diff --git a/tests/ui/dis/ptr_write.stderr b/tests/ui/dis/ptr_write.stderr index a3442ed57d..332eab0871 100644 --- a/tests/ui/dis/ptr_write.stderr +++ b/tests/ui/dis/ptr_write.stderr @@ -2,10 +2,10 @@ %4 = OpFunctionParameter %5 %6 = OpFunctionParameter %5 %7 = OpLabel -OpLine %8 7 35 +OpLine %8 9 35 %9 = OpLoad %10 %4 OpLine %11 1336 8 OpStore %6 %9 -OpLine %8 8 1 +OpNoLine OpReturn OpFunctionEnd diff --git a/tests/ui/dis/ptr_write_method.rs b/tests/ui/dis/ptr_write_method.rs index bdc969df38..fa8aa09ba8 100644 --- a/tests/ui/dis/ptr_write_method.rs +++ b/tests/ui/dis/ptr_write_method.rs @@ -1,3 +1,5 @@ +// normalize-stderr-not_spirt "OpLine %8 10 1" -> "OpNoLine" + // build-pass // compile-flags: -C llvm-args=--disassemble-fn=ptr_write_method::copy_via_raw_ptr diff --git a/tests/ui/dis/ptr_write_method.stderr b/tests/ui/dis/ptr_write_method.stderr index 8ea9dae2dc..b14f037688 100644 --- a/tests/ui/dis/ptr_write_method.stderr +++ b/tests/ui/dis/ptr_write_method.stderr @@ -2,10 +2,10 @@ %4 = OpFunctionParameter %5 %6 = OpFunctionParameter %5 %7 = OpLabel -OpLine %8 7 37 +OpLine %8 9 37 %9 = OpLoad %10 %4 OpLine %11 1336 8 OpStore %6 %9 -OpLine %8 8 1 +OpNoLine OpReturn OpFunctionEnd diff --git a/tests/ui/lang/core/unwrap_or.rs b/tests/ui/lang/core/unwrap_or.not_spirt.rs similarity index 74% rename from tests/ui/lang/core/unwrap_or.rs rename to tests/ui/lang/core/unwrap_or.not_spirt.rs index 71efc51bb5..ebb51dc439 100644 --- a/tests/ui/lang/core/unwrap_or.rs +++ b/tests/ui/lang/core/unwrap_or.not_spirt.rs @@ -1,3 +1,6 @@ +// HACK(eddyb) duplicate of unwrap_or.spirt.rs because only-/ignore- do not work with revisions. +// only-not_spirt + // unwrap_or generates some memory-bools (as u8). Test to make sure they're fused away. // OpINotEqual, as well as %bool, should not appear in the output. diff --git a/tests/ui/lang/core/unwrap_or.not_spirt.stderr b/tests/ui/lang/core/unwrap_or.not_spirt.stderr new file mode 100644 index 0000000000..1d2a599a00 --- /dev/null +++ b/tests/ui/lang/core/unwrap_or.not_spirt.stderr @@ -0,0 +1,4 @@ +error: invalid character `'.'` in crate name: `unwrap_or.not_spirt` + +error: aborting due to previous error + diff --git a/tests/ui/lang/core/unwrap_or.spirt.rs b/tests/ui/lang/core/unwrap_or.spirt.rs new file mode 100644 index 0000000000..1e8b04e5c2 --- /dev/null +++ b/tests/ui/lang/core/unwrap_or.spirt.rs @@ -0,0 +1,15 @@ +// HACK(eddyb) duplicate of unwrap_or.not_spirt.rs because only-/ignore- do not work with revisions. +// only-spirt + +// unwrap_or generates some memory-bools (as u8). Test to make sure they're fused away. +// OpINotEqual, as well as %bool, should not appear in the output. + +// build-pass +// compile-flags: -C llvm-args=--disassemble-entry=main + +use spirv_std::spirv; + +#[spirv(fragment)] +pub fn main(out: &mut u32) { + *out = None.unwrap_or(15); +} diff --git a/tests/ui/lang/core/unwrap_or.spirt.stderr b/tests/ui/lang/core/unwrap_or.spirt.stderr new file mode 100644 index 0000000000..2d7ca37b7f --- /dev/null +++ b/tests/ui/lang/core/unwrap_or.spirt.stderr @@ -0,0 +1,4 @@ +error: invalid character `'.'` in crate name: `unwrap_or.spirt` + +error: aborting due to previous error + diff --git a/tests/ui/lang/core/unwrap_or.stderr b/tests/ui/lang/core/unwrap_or.stderr deleted file mode 100644 index 37b092466a..0000000000 --- a/tests/ui/lang/core/unwrap_or.stderr +++ /dev/null @@ -1,39 +0,0 @@ -%1 = OpFunction %2 None %3 -%4 = OpLabel -OpLine %5 11 11 -%6 = OpCompositeInsert %7 %8 %9 0 -OpLine %5 11 11 -%10 = OpCompositeExtract %11 %6 1 -OpLine %12 803 14 -%13 = OpBitcast %14 %8 -OpLine %12 803 8 -OpSelectionMerge %15 None -OpSwitch %13 %16 0 %17 1 %18 -%16 = OpLabel -OpLine %12 803 14 -OpUnreachable -%17 = OpLabel -OpLine %12 805 20 -OpBranch %15 -%18 = OpLabel -OpLine %12 804 23 -OpBranch %15 -%15 = OpLabel -%19 = OpPhi %20 %21 %17 %22 %18 -%23 = OpPhi %11 %24 %17 %10 %18 -OpBranch %25 -%25 = OpLabel -OpLine %12 807 4 -OpSelectionMerge %26 None -OpBranchConditional %19 %27 %28 -%27 = OpLabel -OpLine %12 807 4 -OpBranch %26 -%28 = OpLabel -OpBranch %26 -%26 = OpLabel -OpLine %5 11 4 -OpStore %29 %23 -OpLine %5 12 1 -OpReturn -OpFunctionEnd