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

MIR validation error at mir-opt-level>=3 #117355

Closed
cbeuw opened this issue Oct 29, 2023 · 1 comment · Fixed by #117783
Closed

MIR validation error at mir-opt-level>=3 #117355

cbeuw opened this issue Oct 29, 2023 · 1 comment · Fixed by #117783
Labels
A-mir-opt Area: MIR optimizations A-mir-opt-inlining Area: MIR inlining C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@cbeuw
Copy link
Contributor

cbeuw commented Oct 29, 2023

#![feature(custom_mir, core_intrinsics)]
#![allow(unused_parens, unused_assignments, overflowing_literals)]
extern crate core;
use core::intrinsics::mir::*;

#[custom_mir(dialect = "runtime", phase = "initial")]
pub fn fn12(
    mut _6: *mut bool,
    mut _9: *mut bool,
) -> char {
    mir! {
    let _19: i8;
    {
    Goto(bb1)
    }
    bb1 = {
    Call((*_9) = fn13(_6), bb2)
    }
    bb2 = {
    _19 = 115_i8;
    match _19 {
    1 => bb3,
    _ => bb5
    }
    }
    bb3 = {
    Call((*_9) = fn13(_6), bb2)
    }
    bb5 = {
    Return()
    }

    }
}
#[custom_mir(dialect = "runtime", phase = "initial")]
fn fn13(mut _1: *mut bool) -> bool {
    mir! {
    {
    RET = true;
    Return()
    }
    }
}
pub fn main() {}

This compiles fine with rustc -Zmir-opt-level=2 -Copt-level=1 repro.rs, but

% rustc -Zmir-opt-level=3 -Copt-level=1 repro.rs
warning: the feature `custom_mir` is internal to the compiler or standard library
 --> repro.rs:1:12
  |
1 | #![feature(custom_mir, core_intrinsics)]
  |            ^^^^^^^^^^
  |
  = note: using it is strongly discouraged
  = note: `#[warn(internal_features)]` on by default

warning: 1 warning emitted

error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: broken MIR in Item(DefId(0:5 ~ repro[f81f]::fn12)) (after phase change to runtime-optimized) at bb0[1]:
                                use of local _4, which has no storage here
  --> repro.rs:27:18
   |
27 |     Call((*_9) = fn13(_6), bb2)
   |                  ^^^^^^^^
   |
note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:310:22
         0: std::backtrace::Backtrace::create
         1: <rustc_errors::HandlerInner>::emit_diagnostic
         2: <rustc_errors::Handler>::delay_span_bug::<rustc_span::span_encoding::Span, alloc::string::String>
         3: <rustc_const_eval::transform::validate::CfgChecker>::fail::<alloc::string::String>
         4: <rustc_const_eval::transform::validate::CfgChecker as rustc_middle::mir::visit::Visitor>::visit_local
         5: <rustc_const_eval::transform::validate::CfgChecker as rustc_middle::mir::visit::Visitor>::visit_statement
         6: <rustc_const_eval::transform::validate::Validator as rustc_middle::mir::MirPass>::run_pass
         7: rustc_mir_transform::pass_manager::run_passes_inner
         8: rustc_mir_transform::optimized_mir
         9: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        10: <rustc_query_impl::query_impl::optimized_mir::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::DefId)>>::call_once
        11: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::DefId, rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        12: rustc_query_impl::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
        13: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::DefId, rustc_middle::query::erase::Erased<[u8; 8]>>>
        14: rustc_mir_transform::cross_crate_inline::cross_crate_inlinable
        15: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::cross_crate_inlinable::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
        16: <rustc_query_impl::query_impl::cross_crate_inlinable::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::DefId)>>::call_once
        17: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::DefId, rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        18: rustc_query_impl::query_impl::cross_crate_inlinable::get_query_non_incr::__rust_end_short_backtrace
        19: rustc_passes::reachable::item_might_be_inlined
        20: rustc_passes::reachable::reachable_set
        21: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::reachable_set::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        22: <rustc_query_impl::query_impl::reachable_set::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, ())>>::call_once
        23: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        24: rustc_query_impl::query_impl::reachable_set::get_query_non_incr::__rust_end_short_backtrace
        25: rustc_codegen_ssa::back::symbol_export::reachable_non_generics_provider
        26: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::reachable_non_generics::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        27: <rustc_query_impl::query_impl::reachable_non_generics::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::CrateNum)>>::call_once
        28: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::VecCache<rustc_span::def_id::CrateNum, rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        29: rustc_query_impl::query_impl::reachable_non_generics::get_query_non_incr::__rust_end_short_backtrace
        30: rustc_codegen_ssa::back::symbol_export::is_reachable_non_generic_provider_local
        31: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::is_reachable_non_generic::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
        32: <rustc_query_impl::query_impl::is_reachable_non_generic::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::DefId)>>::call_once
        33: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::DefId, rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        34: rustc_query_impl::query_impl::is_reachable_non_generic::get_query_non_incr::__rust_end_short_backtrace
        35: <rustc_monomorphize::collector::RootCollector>::push_if_root
        36: rustc_monomorphize::collector::collect_roots
        37: rustc_monomorphize::collector::collect_crate_mono_items
        38: rustc_monomorphize::partitioning::collect_and_partition_mono_items
        39: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 24]>>
        40: <rustc_query_impl::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, ())>>::call_once
        41: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 24]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        42: rustc_query_impl::query_impl::collect_and_partition_mono_items::get_query_non_incr::__rust_end_short_backtrace
        43: rustc_codegen_ssa::base::codegen_crate::<rustc_codegen_llvm::LlvmCodegenBackend>
        44: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
        45: <rustc_session::session::Session>::time::<alloc::boxed::Box<dyn core::any::Any>, rustc_interface::passes::start_codegen::{closure#0}>
        46: rustc_interface::passes::start_codegen
        47: <rustc_middle::ty::context::GlobalCtxt>::enter::<<rustc_interface::queries::Queries>::ongoing_codegen::{closure#0}, core::result::Result<alloc::boxed::Box<dyn core::any::Any>, rustc_span::ErrorGuaranteed>>
        48: <rustc_interface::queries::Queries>::ongoing_codegen
        49: rustc_span::set_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
        50: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
        51: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
        52: std::sys::unix::thread::Thread::new::thread_start
        53: __pthread_joiner_wake
  --> repro.rs:27:18
   |
27 |     Call((*_9) = fn13(_6), bb2)
   |                  ^^^^^^^^

error: internal compiler error: broken MIR in Item(DefId(0:5 ~ repro[f81f]::fn12)) (after phase change to runtime-optimized) at bb0[1]:
                                use of local _5, which has no storage here
  --> repro.rs:27:18
   |
27 |     Call((*_9) = fn13(_6), bb2)
   |                  ^^^^^^^^
   |
note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:310:22
         0: std::backtrace::Backtrace::create
         1: <rustc_errors::HandlerInner>::emit_diagnostic
         2: <rustc_errors::Handler>::delay_span_bug::<rustc_span::span_encoding::Span, alloc::string::String>
         3: <rustc_const_eval::transform::validate::CfgChecker>::fail::<alloc::string::String>
         4: <rustc_const_eval::transform::validate::CfgChecker as rustc_middle::mir::visit::Visitor>::visit_local
         5: <rustc_const_eval::transform::validate::CfgChecker as rustc_middle::mir::visit::Visitor>::visit_place
         6: <rustc_const_eval::transform::validate::CfgChecker as rustc_middle::mir::visit::Visitor>::visit_statement
         7: <rustc_const_eval::transform::validate::Validator as rustc_middle::mir::MirPass>::run_pass
         8: rustc_mir_transform::pass_manager::run_passes_inner
         9: rustc_mir_transform::optimized_mir
        10: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        11: <rustc_query_impl::query_impl::optimized_mir::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::DefId)>>::call_once
        12: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::DefId, rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        13: rustc_query_impl::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
        14: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::DefId, rustc_middle::query::erase::Erased<[u8; 8]>>>
        15: rustc_mir_transform::cross_crate_inline::cross_crate_inlinable
        16: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::cross_crate_inlinable::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
        17: <rustc_query_impl::query_impl::cross_crate_inlinable::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::DefId)>>::call_once
        18: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::DefId, rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        19: rustc_query_impl::query_impl::cross_crate_inlinable::get_query_non_incr::__rust_end_short_backtrace
        20: rustc_passes::reachable::item_might_be_inlined
        21: rustc_passes::reachable::reachable_set
        22: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::reachable_set::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        23: <rustc_query_impl::query_impl::reachable_set::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, ())>>::call_once
        24: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        25: rustc_query_impl::query_impl::reachable_set::get_query_non_incr::__rust_end_short_backtrace
        26: rustc_codegen_ssa::back::symbol_export::reachable_non_generics_provider
        27: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::reachable_non_generics::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        28: <rustc_query_impl::query_impl::reachable_non_generics::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::CrateNum)>>::call_once
        29: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::VecCache<rustc_span::def_id::CrateNum, rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        30: rustc_query_impl::query_impl::reachable_non_generics::get_query_non_incr::__rust_end_short_backtrace
        31: rustc_codegen_ssa::back::symbol_export::is_reachable_non_generic_provider_local
        32: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::is_reachable_non_generic::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
        33: <rustc_query_impl::query_impl::is_reachable_non_generic::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::DefId)>>::call_once
        34: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::DefId, rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        35: rustc_query_impl::query_impl::is_reachable_non_generic::get_query_non_incr::__rust_end_short_backtrace
        36: <rustc_monomorphize::collector::RootCollector>::push_if_root
        37: rustc_monomorphize::collector::collect_roots
        38: rustc_monomorphize::collector::collect_crate_mono_items
        39: rustc_monomorphize::partitioning::collect_and_partition_mono_items
        40: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 24]>>
        41: <rustc_query_impl::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, ())>>::call_once
        42: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 24]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        43: rustc_query_impl::query_impl::collect_and_partition_mono_items::get_query_non_incr::__rust_end_short_backtrace
        44: rustc_codegen_ssa::base::codegen_crate::<rustc_codegen_llvm::LlvmCodegenBackend>
        45: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
        46: <rustc_session::session::Session>::time::<alloc::boxed::Box<dyn core::any::Any>, rustc_interface::passes::start_codegen::{closure#0}>
        47: rustc_interface::passes::start_codegen
        48: <rustc_middle::ty::context::GlobalCtxt>::enter::<<rustc_interface::queries::Queries>::ongoing_codegen::{closure#0}, core::result::Result<alloc::boxed::Box<dyn core::any::Any>, rustc_span::ErrorGuaranteed>>
        49: <rustc_interface::queries::Queries>::ongoing_codegen
        50: rustc_span::set_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
        51: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
        52: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
        53: std::sys::unix::thread::Thread::new::thread_start
        54: __pthread_joiner_wake
  --> repro.rs:27:18
   |
27 |     Call((*_9) = fn13(_6), bb2)
   |                  ^^^^^^^^

note: using internal features is not supported and expected to cause internal compiler errors when used incorrectly

note: please attach the file at `/Users/andy/Code/rustlantis/rustc-ice-2023-10-29T11_56_45-53492.txt` to your bug report

note: compiler flags: -Z mir-opt-level=3 -C opt-level=1

query stack during panic:
end of query stack
% rustc -v --version
rustc 1.75.0-nightly (e5cfc5547 2023-10-28)
binary: rustc
commit-hash: e5cfc55477eceed1317a02189fdf77a4a98f2124
commit-date: 2023-10-28
host: aarch64-apple-darwin
release: 1.75.0-nightly
LLVM version: 17.0.3
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 29, 2023
@Noratrieb Noratrieb added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. A-mir-opt Area: MIR optimizations and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Oct 29, 2023
@saethlin saethlin added the A-mir-opt-inlining Area: MIR inlining label Oct 29, 2023
@saethlin
Copy link
Member

saethlin commented Oct 29, 2023

The minimal set of flags to trip this is:

-Copt-level=1 -Zmir-enable-passes=+ConstProp -Zinline-mir

I think you need -Copt-level=1 because if I add -Ztreat-err-as-bug we can see this is hit from cross_crate_inlinable:

#0 [optimized_mir] optimizing MIR for `fn12`
#1 [cross_crate_inlinable] whether the item should be made inlinable across crates
#2 [reachable_set] reachability
#3 [reachable_non_generics] looking up the exported symbols of a crate
#4 [is_reachable_non_generic] checking whether `fn12` is an exported symbol
#5 [collect_and_partition_mono_items] collect_and_partition_mono_items

bors added a commit to rust-lang-ci/rust that referenced this issue Oct 29, 2023
…ine, r=<try>

Enable cross-crate-inlining when MIR inlining is enabled

This would make rust-lang#117355 generally less obscure, and also seems like a good idea, even if for some reason someone wants MIR opts but no codegen opts.
bors added a commit to rust-lang-ci/rust that referenced this issue Oct 31, 2023
…ine, r=tmiasko

Enable cross-crate-inlining when MIR inlining is enabled

This would make rust-lang#117355 generally less obscure, and also seems like a good idea, even if for some reason someone wants MIR opts but no codegen opts.
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Nov 2, 2023
…iasko

Enable cross-crate-inlining when MIR inlining is enabled

This would make rust-lang/rust#117355 generally less obscure, and also seems like a good idea, even if for some reason someone wants MIR opts but no codegen opts.
@tmiasko tmiasko self-assigned this Nov 9, 2023
tmiasko added a commit to tmiasko/rust that referenced this issue Nov 10, 2023
Inlining creates additional statements to be executed along the return
edge: an assignment to the destination, storage end for temporaries.

Previously those statements where inserted directly into a call target,
but this is incorrect when the target has other predecessors.

Avoid the issue by creating a new dedicated block for those statements.
When the block happens to be redundant it will be removed by CFG
simplification that follows inlining.

Fixes rust-lang#117355
@tmiasko tmiasko removed their assignment Nov 10, 2023
bors added a commit to rust-lang-ci/rust that referenced this issue Nov 14, 2023
 Fix insertion of statements to be executed along return edge in inlining

Inlining creates additional statements to be executed along the return
edge: an assignment to the destination, storage end for temporaries.

Previously those statements where inserted directly into a call target,
but this is incorrect when the target has other predecessors.

Avoid the issue by creating a new dedicated block for those statements.
When the block happens to be redundant it will be removed by CFG
simplification that follows inlining.

Fixes rust-lang#117355
bors added a commit to rust-lang-ci/rust that referenced this issue Nov 19, 2023
 Fix insertion of statements to be executed along return edge in inlining

Inlining creates additional statements to be executed along the return
edge: an assignment to the destination, storage end for temporaries.

Previously those statements where inserted directly into a call target,
but this is incorrect when the target has other predecessors.

Avoid the issue by creating a new dedicated block for those statements.
When the block happens to be redundant it will be removed by CFG
simplification that follows inlining.

Fixes rust-lang#117355
tmiasko added a commit to tmiasko/rust that referenced this issue Nov 19, 2023
Inlining creates additional statements to be executed along the return
edge: an assignment to the destination, storage end for temporaries.

Previously those statements where inserted directly into a call target,
but this is incorrect when the target has other predecessors.

Avoid the issue by creating a new dedicated block for those statements.
When the block happens to be redundant it will be removed by CFG
simplification that follows inlining.

Fixes rust-lang#117355
bors added a commit to rust-lang-ci/rust that referenced this issue Nov 20, 2023
 Fix insertion of statements to be executed along return edge in inlining

Inlining creates additional statements to be executed along the return
edge: an assignment to the destination, storage end for temporaries.

Previously those statements where inserted directly into a call target,
but this is incorrect when the target has other predecessors.

Avoid the issue by creating a new dedicated block for those statements.
When the block happens to be redundant it will be removed by CFG
simplification that follows inlining.

Fixes rust-lang#117355
bors added a commit to rust-lang-ci/rust that referenced this issue Nov 20, 2023
 Fix insertion of statements to be executed along return edge in inlining

Inlining creates additional statements to be executed along the return
edge: an assignment to the destination, storage end for temporaries.

Previously those statements where inserted directly into a call target,
but this is incorrect when the target has other predecessors.

Avoid the issue by creating a new dedicated block for those statements.
When the block happens to be redundant it will be removed by CFG
simplification that follows inlining.

Fixes rust-lang#117355
@bors bors closed this as completed in 1be1c2e Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-mir-opt Area: MIR optimizations A-mir-opt-inlining Area: MIR inlining C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants