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

Rollup of 10 pull requests #78232

Closed
wants to merge 43 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
3b37d94
Add some tests
Nadrieril Oct 17, 2020
bb81110
Destructure byte array constants to array patterns instead of keeping…
oli-obk Sep 29, 2020
c3d0445
Destructure byte slices and remove all the workarounds
oli-obk Oct 1, 2020
99852e0
A ConstantValue constructor with a slice pattern is an error
Nadrieril Oct 17, 2020
3708c86
Treat booleans as integers with valid range 0..=1
oli-obk Oct 2, 2020
f504e9a
Fix comment
Nadrieril Oct 17, 2020
aa41720
Handle ranges of float consistently
Nadrieril Oct 17, 2020
d1a784e
Treat string literals separately from other constants
Nadrieril Oct 17, 2020
da0ba2f
The only remaining constant patterns are opaque
Nadrieril Oct 18, 2020
c4ae6c2
Add comment
Nadrieril Oct 18, 2020
13a5067
Unignore test
Oct 13, 2020
0558e6e
bootstrap: fall back to auto-detected CXX
jonas-schievink Oct 14, 2020
77a7ccf
bootstrap: configure native toolchain for run-make
jonas-schievink Oct 14, 2020
e36de6b
Move issue-36710 test to run-make
jonas-schievink Oct 14, 2020
a671604
Ignore test on WASM
jonas-schievink Oct 14, 2020
d7c7649
ignore-thumb
jonas-schievink Oct 16, 2020
60594b1
Ignore on 32-bit targets
Oct 19, 2020
2780e35
Throw core::panic!("message") as &str instead of String.
m-ou-se Oct 19, 2020
9890217
Fix ui test for updated core::panic behaviour.
m-ou-se Oct 19, 2020
d80f127
Avoid panic_bounds_check in fmt::write.
m-ou-se Oct 19, 2020
5bfd3e7
Accidentally fixed #78071
Nadrieril Oct 19, 2020
ea24395
Add debug_asserts for the unsafe indexing in fmt::write.
m-ou-se Oct 20, 2020
5948e62
Sync LLVM submodule if it has been initialized
est31 Oct 20, 2020
356d5b5
Add test to check for fmt::write bloat.
m-ou-se Oct 20, 2020
e852a4a
Update cargo
ehuss Oct 20, 2020
52640f2
[mir-opt] Allow debuginfo to be generated for a constant or a Place
wesleywiser May 30, 2020
2202653
Miri engine validity check: simplify code with 'matches!'
RalfJung Oct 21, 2020
fcaf233
Miri engine interning: improve comments, and entirely skip ZST
RalfJung Oct 21, 2020
3519411
Add a test for #53708
Nadrieril Oct 21, 2020
faf8710
Explain the `Opaque` special case in specialization
Nadrieril Oct 21, 2020
484d9eb
Move fmt-write-bloat test to run-make-fulldeps.
m-ou-se Oct 21, 2020
3a58ad9
Update `compiler_builtins` to 0.1.36
JohnTitor Oct 21, 2020
10d6f2d
Add regression test for #73298
varkor Oct 21, 2020
7fecaca
Rollup merge of #73210 - wesleywiser:consts_in_debuginfo, r=oli-obk
Dylan-DPC Oct 22, 2020
80897de
Rollup merge of #77901 - jonas-schievink:unignore-test-36710, r=Mark-…
Dylan-DPC Oct 22, 2020
d08f484
Rollup merge of #78072 - Nadrieril:cleanup-constant-matching, r=varkor
Dylan-DPC Oct 22, 2020
4b223d7
Rollup merge of #78119 - fusion-engineering-forks:panic-use-as-str, r…
Dylan-DPC Oct 22, 2020
4816d30
Rollup merge of #78122 - fusion-engineering-forks:fmt-write-bounds-ch…
Dylan-DPC Oct 22, 2020
8b861e3
Rollup merge of #78153 - est31:downloaded_llvm_maybe_sync, r=Mark-Sim…
Dylan-DPC Oct 22, 2020
faa1d37
Rollup merge of #78169 - ehuss:update-cargo, r=ehuss
Dylan-DPC Oct 22, 2020
03a4fcb
Rollup merge of #78179 - RalfJung:miri-comments, r=oli-obk
Dylan-DPC Oct 22, 2020
db12963
Rollup merge of #78207 - varkor:issue-73298, r=lcnr
Dylan-DPC Oct 22, 2020
62ffb30
Rollup merge of #78209 - JohnTitor:compiler-builtins, r=Amanieu
Dylan-DPC Oct 22, 2020
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
19 changes: 16 additions & 3 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ dependencies = [
"crypto-hash",
"curl",
"curl-sys",
"env_logger 0.7.1",
"env_logger 0.8.1",
"filetime",
"flate2",
"fwdansi",
Expand Down Expand Up @@ -626,9 +626,9 @@ dependencies = [

[[package]]
name = "compiler_builtins"
version = "0.1.35"
version = "0.1.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3fcd8aba10d17504c87ef12d4f62ef404c6a4703d16682a9eb5543e6cf24455"
checksum = "7cd0782e0a7da7598164153173e5a5d4d9b1da094473c98dce0ff91406112369"
dependencies = [
"cc",
"rustc-std-workspace-core",
Expand Down Expand Up @@ -1035,6 +1035,19 @@ dependencies = [
"termcolor",
]

[[package]]
name = "env_logger"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "54532e3223c5af90a6a757c90b5c5521564b07e5e7a958681bcd2afad421cdcd"
dependencies = [
"atty",
"humantime 2.0.1",
"log",
"regex",
"termcolor",
]

[[package]]
name = "error_index_generator"
version = "0.0.0"
Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1416,10 +1416,11 @@ fn generator_layout_and_saved_local_names(

let state_arg = mir::Local::new(1);
for var in &body.var_debug_info {
if var.place.local != state_arg {
let place = if let mir::VarDebugInfoContents::Place(p) = var.value { p } else { continue };
if place.local != state_arg {
continue;
}
match var.place.projection[..] {
match place.projection[..] {
[
// Deref of the `Pin<&mut Self>` state argument.
mir::ProjectionElem::Field(..),
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_ssa/src/mir/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use super::FunctionCx;

impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
pub fn eval_mir_constant_to_operand(
&mut self,
&self,
bx: &mut Bx,
constant: &mir::Constant<'tcx>,
) -> Result<OperandRef<'tcx, Bx::Value>, ErrorHandled> {
Expand All @@ -21,7 +21,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
}

pub fn eval_mir_constant(
&mut self,
&self,
constant: &mir::Constant<'tcx>,
) -> Result<ConstValue<'tcx>, ErrorHandled> {
match self.monomorphize(&constant.literal).val {
Expand Down
100 changes: 67 additions & 33 deletions compiler/rustc_codegen_ssa/src/mir/debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_span::symbol::{kw, Symbol};
use rustc_span::{BytePos, Span};
use rustc_target::abi::{LayoutOf, Size};

use super::operand::OperandValue;
use super::operand::{OperandRef, OperandValue};
use super::place::PlaceRef;
use super::{FunctionCx, LocalRef};

Expand Down Expand Up @@ -111,6 +111,24 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
}
}

fn spill_operand_to_stack(
operand: &OperandRef<'tcx, Bx::Value>,
name: Option<String>,
bx: &mut Bx,
) -> PlaceRef<'tcx, Bx::Value> {
// "Spill" the value onto the stack, for debuginfo,
// without forcing non-debuginfo uses of the local
// to also load from the stack every single time.
// FIXME(#68817) use `llvm.dbg.value` instead,
// at least for the cases which LLVM handles correctly.
let spill_slot = PlaceRef::alloca(bx, operand.layout);
if let Some(name) = name {
bx.set_var_name(spill_slot.llval, &(name + ".dbg.spill"));
}
operand.val.store(bx, spill_slot);
spill_slot
}

/// Apply debuginfo and/or name, after creating the `alloca` for a local,
/// or initializing the local with an operand (whichever applies).
pub fn debug_introduce_local(&self, bx: &mut Bx, local: mir::Local) {
Expand Down Expand Up @@ -225,17 +243,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
return;
}

// "Spill" the value onto the stack, for debuginfo,
// without forcing non-debuginfo uses of the local
// to also load from the stack every single time.
// FIXME(#68817) use `llvm.dbg.value` instead,
// at least for the cases which LLVM handles correctly.
let spill_slot = PlaceRef::alloca(bx, operand.layout);
if let Some(name) = name {
bx.set_var_name(spill_slot.llval, &(name + ".dbg.spill"));
}
operand.val.store(bx, spill_slot);
spill_slot
Self::spill_operand_to_stack(operand, name, bx)
}

LocalRef::Place(place) => *place,
Expand Down Expand Up @@ -310,6 +318,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
/// Partition all `VarDebugInfo` in `self.mir`, by their base `Local`.
pub fn compute_per_local_var_debug_info(
&self,
bx: &mut Bx,
) -> Option<IndexVec<mir::Local, Vec<PerLocalVarDebugInfo<'tcx, Bx::DIVariable>>>> {
let full_debug_info = self.cx.sess().opts.debuginfo == DebugInfo::Full;

Expand All @@ -324,22 +333,30 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
} else {
(None, var.source_info.span)
};
let (var_ty, var_kind) = match var.value {
mir::VarDebugInfoContents::Place(place) => {
let var_ty = self.monomorphized_place_ty(place.as_ref());
let var_kind = if self.mir.local_kind(place.local) == mir::LocalKind::Arg
&& place.projection.is_empty()
&& var.source_info.scope == mir::OUTERMOST_SOURCE_SCOPE
{
let arg_index = place.local.index() - 1;

// FIXME(eddyb) shouldn't `ArgumentVariable` indices be
// offset in closures to account for the hidden environment?
// Also, is this `+ 1` needed at all?
VariableKind::ArgumentVariable(arg_index + 1)
} else {
VariableKind::LocalVariable
};
(var_ty, var_kind)
}
mir::VarDebugInfoContents::Const(c) => {
let ty = self.monomorphize(&c.literal.ty);
(ty, VariableKind::LocalVariable)
}
};
let dbg_var = scope.map(|scope| {
let place = var.place;
let var_ty = self.monomorphized_place_ty(place.as_ref());
let var_kind = if self.mir.local_kind(place.local) == mir::LocalKind::Arg
&& place.projection.is_empty()
&& var.source_info.scope == mir::OUTERMOST_SOURCE_SCOPE
{
let arg_index = place.local.index() - 1;

// FIXME(eddyb) shouldn't `ArgumentVariable` indices be
// offset in closures to account for the hidden environment?
// Also, is this `+ 1` needed at all?
VariableKind::ArgumentVariable(arg_index + 1)
} else {
VariableKind::LocalVariable
};
self.cx.create_dbg_var(
self.debug_context.as_ref().unwrap(),
var.name,
Expand All @@ -350,12 +367,29 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
)
});

per_local[var.place.local].push(PerLocalVarDebugInfo {
name: var.name,
source_info: var.source_info,
dbg_var,
projection: var.place.projection,
});
match var.value {
mir::VarDebugInfoContents::Place(place) => {
per_local[place.local].push(PerLocalVarDebugInfo {
name: var.name,
source_info: var.source_info,
dbg_var,
projection: place.projection,
});
}
mir::VarDebugInfoContents::Const(c) => {
if let (Some(scope), Some(dbg_var)) = (scope, dbg_var) {
if let Ok(operand) = self.eval_mir_constant_to_operand(bx, &c) {
let base = Self::spill_operand_to_stack(
&operand,
Some(var.name.to_string()),
bx,
);

bx.dbg_var_addr(dbg_var, scope, base.llval, Size::ZERO, &[], span);
}
}
}
}
}
Some(per_local)
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
caller_location: None,
};

fx.per_local_var_debug_info = fx.compute_per_local_var_debug_info();
fx.per_local_var_debug_info = fx.compute_per_local_var_debug_info(&mut bx);

for const_ in &mir.required_consts {
if let Err(err) = fx.eval_mir_constant(const_) {
Expand Down
21 changes: 18 additions & 3 deletions compiler/rustc_middle/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1071,6 +1071,23 @@ impl<'tcx> LocalDecl<'tcx> {
}
}

#[derive(Clone, TyEncodable, TyDecodable, HashStable, TypeFoldable)]
pub enum VarDebugInfoContents<'tcx> {
/// NOTE(eddyb) There's an unenforced invariant that this `Place` is
/// based on a `Local`, not a `Static`, and contains no indexing.
Place(Place<'tcx>),
Const(Constant<'tcx>),
}

impl<'tcx> Debug for VarDebugInfoContents<'tcx> {
fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
match self {
VarDebugInfoContents::Const(c) => write!(fmt, "{}", c),
VarDebugInfoContents::Place(p) => write!(fmt, "{:?}", p),
}
}
}

/// Debug information pertaining to a user variable.
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable)]
pub struct VarDebugInfo<'tcx> {
Expand All @@ -1082,9 +1099,7 @@ pub struct VarDebugInfo<'tcx> {
pub source_info: SourceInfo,

/// Where the data for this user variable is to be found.
/// NOTE(eddyb) There's an unenforced invariant that this `Place` is
/// based on a `Local`, not a `Static`, and contains no indexing.
pub place: Place<'tcx>,
pub value: VarDebugInfoContents<'tcx>,
}

///////////////////////////////////////////////////////////////////////////
Expand Down
16 changes: 10 additions & 6 deletions compiler/rustc_middle/src/mir/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -796,16 +796,20 @@ macro_rules! make_mir_visitor {
let VarDebugInfo {
name: _,
source_info,
place,
value,
} = var_debug_info;

self.visit_source_info(source_info);
let location = START_BLOCK.start_location();
self.visit_place(
place,
PlaceContext::NonUse(NonUseContext::VarDebugInfo),
location,
);
match value {
VarDebugInfoContents::Const(c) => self.visit_constant(c, location),
VarDebugInfoContents::Place(place) =>
self.visit_place(
place,
PlaceContext::NonUse(NonUseContext::VarDebugInfo),
location
),
}
}

fn super_source_scope(&mut self,
Expand Down
26 changes: 14 additions & 12 deletions compiler/rustc_mir/src/borrow_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use rustc_index::vec::IndexVec;
use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
use rustc_middle::mir::{
traversal, Body, ClearCrossCrate, Local, Location, Mutability, Operand, Place, PlaceElem,
PlaceRef,
PlaceRef, VarDebugInfoContents,
};
use rustc_middle::mir::{AggregateKind, BasicBlock, BorrowCheckResult, BorrowKind};
use rustc_middle::mir::{Field, ProjectionElem, Promoted, Rvalue, Statement, StatementKind};
Expand Down Expand Up @@ -133,19 +133,21 @@ fn do_mir_borrowck<'a, 'tcx>(

let mut local_names = IndexVec::from_elem(None, &input_body.local_decls);
for var_debug_info in &input_body.var_debug_info {
if let Some(local) = var_debug_info.place.as_local() {
if let Some(prev_name) = local_names[local] {
if var_debug_info.name != prev_name {
span_bug!(
var_debug_info.source_info.span,
"local {:?} has many names (`{}` vs `{}`)",
local,
prev_name,
var_debug_info.name
);
if let VarDebugInfoContents::Place(place) = var_debug_info.value {
if let Some(local) = place.as_local() {
if let Some(prev_name) = local_names[local] {
if var_debug_info.name != prev_name {
span_bug!(
var_debug_info.source_info.span,
"local {:?} has many names (`{}` vs `{}`)",
local,
prev_name,
var_debug_info.name
);
}
}
local_names[local] = Some(var_debug_info.name);
}
local_names[local] = Some(var_debug_info.name);
}
}

Expand Down
Loading