Skip to content

Commit a6bfd38

Browse files
eddybLegNeato
authored andcommitted
spirv-builder: disable MIR "GVN" optimization pass.
1 parent d03e379 commit a6bfd38

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

crates/spirv-builder/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,11 @@ fn invoke_rustc(builder: &SpirvBuilder) -> Result<PathBuf, SpirvBuilderError> {
565565
// HACK(eddyb) we need this for `core::fmt::rt::Argument::new_*` calls
566566
// to *never* be inlined, so we can pattern-match the calls themselves.
567567
"-Zinline-mir=off".to_string(),
568+
// HACK(eddyb) similar to turning MIR inlining off, we also can't allow
569+
// optimizations that drastically impact (the quality of) codegen, and
570+
// GVN currently can lead to the memcpy-out-of-const-alloc-global-var
571+
// pattern, even for `ScalarPair` (e.g. `return None::<u32>;`).
572+
"-Zmir-enable-passes=-GVN".to_string(),
568573
];
569574

570575
// Wrapper for `env::var` that appropriately informs Cargo of the dependency.

tests/src/main.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,11 @@ fn rust_flags(codegen_backend_path: &Path) -> String {
345345
// HACK(eddyb) we need this for `core::fmt::rt::Argument::new_*` calls
346346
// to *never* be inlined, so we can pattern-match the calls themselves.
347347
"-Zinline-mir=off",
348+
// HACK(eddyb) similar to turning MIR inlining off, we also can't allow
349+
// optimizations that drastically impact (the quality of) codegen, and
350+
// GVN currently can lead to the memcpy-out-of-const-alloc-global-var
351+
// pattern, even for `ScalarPair` (e.g. `return None::<u32>;`).
352+
"-Zmir-enable-passes=-GVN",
348353
// NOTE(eddyb) flags copied from `spirv-builder` are all above this line.
349354
"-Cdebuginfo=2",
350355
"-Cembed-bitcode=no",

0 commit comments

Comments
 (0)