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

[WIP] NRVO pass for acyclic CFGs #71003

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/librustc_middle/mir/interpret/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,6 @@ pub enum UndefinedBehaviorInfo {
InvalidUndefBytes(Option<Pointer>),
/// Working with a local that is not currently live.
DeadLocal,
/// Trying to read from the return place of a function.
ReadFromReturnPlace,
}

impl fmt::Debug for UndefinedBehaviorInfo {
Expand Down Expand Up @@ -431,7 +429,6 @@ impl fmt::Debug for UndefinedBehaviorInfo {
"using uninitialized data, but this operation requires initialized memory"
),
DeadLocal => write!(f, "accessing a dead local variable"),
ReadFromReturnPlace => write!(f, "tried to read from the return place"),
}
}
}
Expand Down
9 changes: 8 additions & 1 deletion src/librustc_mir/interpret/operand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,14 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
layout: Option<TyAndLayout<'tcx>>,
) -> InterpResult<'tcx, OpTy<'tcx, M::PointerTag>> {
let base_op = match place.local {
mir::RETURN_PLACE => throw_ub!(ReadFromReturnPlace),
mir::RETURN_PLACE => {
if let Some(place) = self.frame().return_place {
self.place_to_op(place)?
} else {
// Tried to access return place, but the function cannot return
throw_ub!(Unreachable)
}
}
local => {
// Do not use the layout passed in as argument if the base we are looking at
// here is not the entire place.
Expand Down
1 change: 1 addition & 0 deletions src/librustc_mir/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Rust MIR: a lowered representation of Rust.
#![feature(trait_alias)]
#![feature(option_expect_none)]
#![feature(or_patterns)]
#![feature(bindings_after_at)]
#![recursion_limit = "256"]

#[macro_use]
Expand Down
Loading