Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly handle terminators in inline assembly #564

Closed
XAMPPRocky opened this issue Mar 31, 2021 · 2 comments
Closed

Correctly handle terminators in inline assembly #564

XAMPPRocky opened this issue Mar 31, 2021 · 2 comments
Labels
a: ice Issues about internal compiler errors t: bug Something isn't working

Comments

@XAMPPRocky
Copy link
Member

Currently the following assembly code causes a ConsumerError(MismatchedTerminator) ICE.

Code

// build-pass

use spirv_std as _;

#[spirv(any_hit_khr)]
pub fn main() {
    unsafe {
        asm!(r#"OpExtension "SPV_KHR_ray_tracing""#);
        asm!("OpCapability RayTracingKHR", "OpTerminateRayKHR");
    }
}

Error

thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: ConsumerError(MismatchedTerminator)', crates/rustc_codegen_spirv/src/link.rs:423:58
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/EmbarkStudios/rust-gpu/issues/new

note: rustc 1.52.0-nightly (61edfd591 2021-03-20) running on x86_64-apple-darwin

note: compiler flags: -Z codegen-backend=/Users/erin.power/src/rust-gpu2/target/release/deps/librustc_codegen_spirv.dylib -Z unstable-options -Z crate-attr=no_std -Z crate-attr=feature(register_attr,asm) -Z crate-attr=register_attr(spirv) -C prefer-dynamic -C overflow-checks=off -C debug-assertions=off -C debuginfo=2 -C embed-bitcode=no --crate-type dylib
@XAMPPRocky XAMPPRocky added t: bug Something isn't working a: ice Issues about internal compiler errors labels Mar 31, 2021
@XAMPPRocky XAMPPRocky changed the title Link panics on ConsumerError(MismatchedTerminator) when using OpTerminateRayKHR. Correctly handle terminators in inline assembly Mar 31, 2021
@XAMPPRocky
Copy link
Member Author

XAMPPRocky commented Mar 31, 2021

Currently you can work around this by adding unused OpLabel at the end of the asm! block. Also to correctly implement terminators on the Rust side changing their type signature to -> !, we need to close #570

asm!("OpKill", "%foo = OpLabel");

@khyperia
Copy link
Contributor

Fixed by #717

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: ice Issues about internal compiler errors t: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants