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 6 pull requests #70648

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
840a576
Move raw string tests into the raw directory
rcoh Mar 28, 2020
4d099e6
Add `-Z dump-mir-dataflow`
ecstatic-morse Mar 28, 2020
edbd7c8
`dump_enabled` takes a `DefId` instead of `MirSource`
ecstatic-morse Mar 28, 2020
c800402
Dump graphviz dataflow results with flag
ecstatic-morse Mar 28, 2020
4d1194c
Ensure output dir for dataflow results exists
ecstatic-morse Mar 28, 2020
629e97a
Improve error messages for raw strings (#60762)
rcoh Mar 28, 2020
c15f86b
Cleanup error messages, improve docstrings
rcoh Mar 29, 2020
82b2989
More raw string tests
rcoh Mar 29, 2020
bceab25
Cleanup match expression
rcoh Mar 29, 2020
20e2190
Clean up redudant conditions and match exprs
rcoh Mar 30, 2020
097e9e5
Add `can_unwind` field to `FnAbi`
wesleywiser Mar 29, 2020
6067315
Ensure LLVM is in the link path for "fulldeps" tests
cuviper Mar 30, 2020
55a5eea
Fix tests to handle debug_assert
rcoh Mar 31, 2020
d45dca3
Use Place directly, it's Copy
spastorino Mar 30, 2020
f026441
Use Place directly on propagate_closure_used_mut_place, it's Copy
spastorino Mar 30, 2020
a67b28a
Use Place directly on borrow_of_local_data, it's Copy
spastorino Mar 30, 2020
32a7618
Use Place directly on remove_never_initialized_mut_locals, it's Copy
spastorino Mar 30, 2020
760bca4
Use Place directly on check_mut_borrowing_layout_constrained_field, i…
spastorino Mar 30, 2020
25528c1
Use Place directly, it's Copy more use cases
spastorino Mar 30, 2020
890b393
Use Place directly, it's Copy even more use cases
spastorino Mar 31, 2020
6a95bf8
Use Place directly on Operand::place and friends, it's Copy
spastorino Mar 31, 2020
f37d2b8
Use Place directly in librustc_mir_build, it's Copy
spastorino Mar 31, 2020
5987b0f
Use Place directly in place_as_reborrow, it's Copy
spastorino Mar 31, 2020
947c1dc
Use Place directly on place_contents_drop_state_cannot_differ, it's Copy
spastorino Mar 31, 2020
017620f
Use Place directly in peek_at, it's Copy
spastorino Mar 31, 2020
afcd7fc
Use Place directly on codegen_drop_terminator, it's Copy
spastorino Mar 31, 2020
5f8a6ed
Use Place directly on make_return_dest, it's Copy
spastorino Mar 31, 2020
1f5338c
Use Place directly in codegen_transmute, it's Copy
spastorino Mar 31, 2020
a865e77
Use Place directly in evaluate_array_len, it's Copy
spastorino Mar 31, 2020
017608f
Use Place directly in codegen_place_to_pointer, it's Copy
spastorino Mar 31, 2020
b46754e
Use Place directly in apply_call_return_effect on framework/tests, it…
spastorino Mar 31, 2020
c7d9d89
Hide `task_context` when lowering body
jonas-schievink Mar 31, 2020
036626f
Address review feedback
wesleywiser Mar 31, 2020
23a7fd4
Rollup merge of #70511 - ecstatic-morse:mir-dataflow-graphviz, r=davi…
Centril Apr 1, 2020
88ff077
Rollup merge of #70522 - rcoh:60762-raw-string-errors, r=petrochenkov
Centril Apr 1, 2020
2885607
Rollup merge of #70547 - wesleywiser:extract_can_unwind, r=eddyb
Centril Apr 1, 2020
3d38918
Rollup merge of #70591 - cuviper:fulldeps-library-path, r=Mark-Simula…
Centril Apr 1, 2020
983e8c9
Rollup merge of #70627 - spastorino:use-place-directly-its-copy, r=ol…
Centril Apr 1, 2020
5a0c0b3
Rollup merge of #70640 - jonas-schievink:async-ice, r=cramertj
Centril Apr 1, 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
11 changes: 10 additions & 1 deletion src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::flags::Subcommand;
use crate::native;
use crate::tool::{self, SourceType, Tool};
use crate::toolstate::ToolState;
use crate::util::{self, dylib_path, dylib_path_var};
use crate::util::{self, add_link_lib_path, dylib_path, dylib_path_var};
use crate::Crate as CargoCrate;
use crate::{envify, DocTests, GitRepo, Mode};

Expand Down Expand Up @@ -1178,6 +1178,15 @@ impl Step for Compiletest {
cmd.arg("--system-llvm");
}

// Tests that use compiler libraries may inherit the `-lLLVM` link
// requirement, but the `-L` library path is not propagated across
// separate compilations. We can add LLVM's library path to the
// platform-specific environment variable as a workaround.
if !builder.config.dry_run && suite.ends_with("fulldeps") {
let llvm_libdir = output(Command::new(&llvm_config).arg("--libdir"));
add_link_lib_path(vec![llvm_libdir.trim().into()], &mut cmd);
}

// Only pass correct values for these flags for the `run-make` suite as it
// requires that a C++ compiler was configured which isn't always the case.
if !builder.config.dry_run && suite == "run-make-fulldeps" {
Expand Down
2 changes: 2 additions & 0 deletions src/librustc_ast_lowering/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -972,8 +972,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
f: impl FnOnce(&mut Self) -> (&'hir [hir::Param<'hir>], hir::Expr<'hir>),
) -> hir::BodyId {
let prev_gen_kind = self.generator_kind.take();
let task_context = self.task_context.take();
let (parameters, result) = f(self);
let body_id = self.record_body(parameters, result);
self.task_context = task_context;
self.generator_kind = prev_gen_kind;
body_id
}
Expand Down
7 changes: 7 additions & 0 deletions src/librustc_codegen_llvm/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,11 @@ impl<'tcx> FnAbiLlvmExt<'tcx> for FnAbi<'tcx, Ty<'tcx>> {
llvm::Attribute::NoReturn.apply_llfn(llvm::AttributePlace::Function, llfn);
}

// FIXME(eddyb, wesleywiser): apply this to callsites as well?
if !self.can_unwind {
llvm::Attribute::NoUnwind.apply_llfn(llvm::AttributePlace::Function, llfn);
}

let mut i = 0;
let mut apply = |attrs: &ArgAttributes, ty: Option<&Type>| {
attrs.apply_llfn(llvm::AttributePlace::Argument(i), llfn, ty);
Expand Down Expand Up @@ -431,6 +436,8 @@ impl<'tcx> FnAbiLlvmExt<'tcx> for FnAbi<'tcx, Ty<'tcx>> {
}

fn apply_attrs_callsite(&self, bx: &mut Builder<'a, 'll, 'tcx>, callsite: &'ll Value) {
// FIXME(wesleywiser, eddyb): We should apply `nounwind` and `noreturn` as appropriate to this callsite.

let mut i = 0;
let mut apply = |attrs: &ArgAttributes, ty: Option<&Type>| {
attrs.apply_callsite(llvm::AttributePlace::Argument(i), callsite, ty);
Expand Down
58 changes: 2 additions & 56 deletions src/librustc_codegen_llvm/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@ use rustc_hir::def_id::{DefId, LOCAL_CRATE};
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use rustc_middle::ty::layout::HasTyCtxt;
use rustc_middle::ty::query::Providers;
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_middle::ty::{self, TyCtxt};
use rustc_session::config::{OptLevel, Sanitizer};
use rustc_session::Session;
use rustc_target::abi::call::Conv;
use rustc_target::spec::PanicStrategy;

use crate::abi::FnAbi;
use crate::attributes;
use crate::llvm::AttributePlace::Function;
use crate::llvm::{self, Attribute};
Expand Down Expand Up @@ -77,12 +74,6 @@ pub fn emit_uwtable(val: &'ll Value, emit: bool) {
Attribute::UWTable.toggle_llfn(Function, val, emit);
}

/// Tell LLVM whether the function can or cannot unwind.
#[inline]
fn unwind(val: &'ll Value, can_unwind: bool) {
Attribute::NoUnwind.toggle_llfn(Function, val, !can_unwind);
}

/// Tell LLVM if this function should be 'naked', i.e., skip the epilogue and prologue.
#[inline]
fn naked(val: &'ll Value, is_naked: bool) {
Expand Down Expand Up @@ -246,12 +237,7 @@ pub(crate) fn default_optimisation_attrs(sess: &Session, llfn: &'ll Value) {

/// Composite function which sets LLVM attributes for function depending on its AST (`#[attribute]`)
/// attributes.
pub fn from_fn_attrs(
cx: &CodegenCx<'ll, 'tcx>,
llfn: &'ll Value,
instance: ty::Instance<'tcx>,
fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
) {
pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty::Instance<'tcx>) {
let codegen_fn_attrs = cx.tcx.codegen_fn_attrs(instance.def_id());

match codegen_fn_attrs.optimize {
Expand Down Expand Up @@ -315,46 +301,6 @@ pub fn from_fn_attrs(
}
sanitize(cx, codegen_fn_attrs.flags, llfn);

unwind(
llfn,
if cx.tcx.sess.panic_strategy() != PanicStrategy::Unwind {
// In panic=abort mode we assume nothing can unwind anywhere, so
// optimize based on this!
false
} else if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::UNWIND) {
// If a specific #[unwind] attribute is present, use that.
true
} else if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::RUSTC_ALLOCATOR_NOUNWIND) {
// Special attribute for allocator functions, which can't unwind.
false
} else {
if fn_abi.conv == Conv::Rust {
// Any Rust method (or `extern "Rust" fn` or `extern
// "rust-call" fn`) is explicitly allowed to unwind
// (unless it has no-unwind attribute, handled above).
true
} else {
// Anything else is either:
//
// 1. A foreign item using a non-Rust ABI (like `extern "C" { fn foo(); }`), or
//
// 2. A Rust item using a non-Rust ABI (like `extern "C" fn foo() { ... }`).
//
// Foreign items (case 1) are assumed to not unwind; it is
// UB otherwise. (At least for now; see also
// rust-lang/rust#63909 and Rust RFC 2753.)
//
// Items defined in Rust with non-Rust ABIs (case 2) are also
// not supposed to unwind. Whether this should be enforced
// (versus stating it is UB) and *how* it would be enforced
// is currently under discussion; see rust-lang/rust#58794.
//
// In either case, we mark item as explicitly nounwind.
false
}
},
);

// Always annotate functions with the target-cpu they are compiled for.
// Without this, ThinLTO won't inline Rust functions into Clang generated
// functions (because Clang annotates functions this way too).
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub fn get_fn(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'tcx>) -> &'ll Value
let llfn = cx.declare_fn(&sym, &fn_abi);
debug!("get_fn: not casting pointer!");

attributes::from_fn_attrs(cx, llfn, instance, &fn_abi);
attributes::from_fn_attrs(cx, llfn, instance);

let instance_def_id = instance.def_id();

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/mono_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl PreDefineMethods<'tcx> for CodegenCx<'ll, 'tcx> {

debug!("predefine_fn: instance = {:?}", instance);

attributes::from_fn_attrs(self, lldecl, instance, &fn_abi);
attributes::from_fn_attrs(self, lldecl, instance);

self.instances.borrow_mut().insert(instance, lldecl);
}
Expand Down
12 changes: 6 additions & 6 deletions src/librustc_codegen_ssa/mir/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
&mut self,
helper: TerminatorCodegenHelper<'tcx>,
mut bx: Bx,
location: &mir::Place<'tcx>,
location: mir::Place<'tcx>,
target: mir::BasicBlock,
unwind: Option<mir::BasicBlock>,
) {
Expand Down Expand Up @@ -580,7 +580,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {

if intrinsic == Some("transmute") {
if let Some(destination_ref) = destination.as_ref() {
let &(ref dest, target) = destination_ref;
let &(dest, target) = destination_ref;
self.codegen_transmute(&mut bx, &args[0], dest);
helper.maybe_sideeffect(self.mir, &mut bx, &[target]);
helper.funclet_br(self, &mut bx, target);
Expand Down Expand Up @@ -619,7 +619,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
let mut llargs = Vec::with_capacity(arg_count);

// Prepare the return value destination
let ret_dest = if let Some((ref dest, _)) = *destination {
let ret_dest = if let Some((dest, _)) = *destination {
let is_intrinsic = intrinsic.is_some();
self.make_return_dest(&mut bx, dest, &fn_abi.ret, &mut llargs, is_intrinsic)
} else {
Expand Down Expand Up @@ -873,7 +873,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
bx.unreachable();
}

mir::TerminatorKind::Drop { ref location, target, unwind } => {
mir::TerminatorKind::Drop { location, target, unwind } => {
self.codegen_drop_terminator(helper, bx, location, target, unwind);
}

Expand Down Expand Up @@ -1123,7 +1123,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
fn make_return_dest(
&mut self,
bx: &mut Bx,
dest: &mir::Place<'tcx>,
dest: mir::Place<'tcx>,
fn_ret: &ArgAbi<'tcx, Ty<'tcx>>,
llargs: &mut Vec<Bx::Value>,
is_intrinsic: bool,
Expand Down Expand Up @@ -1184,7 +1184,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
}
}

fn codegen_transmute(&mut self, bx: &mut Bx, src: &mir::Operand<'tcx>, dst: &mir::Place<'tcx>) {
fn codegen_transmute(&mut self, bx: &mut Bx, src: &mir::Operand<'tcx>, dst: mir::Place<'tcx>) {
if let Some(index) = dst.as_local() {
match self.locals[index] {
LocalRef::Place(place) => self.codegen_transmute_into(bx, src, place),
Expand Down
10 changes: 5 additions & 5 deletions src/librustc_codegen_ssa/mir/rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
(bx, OperandRef { val, layout: cast })
}

mir::Rvalue::Ref(_, bk, ref place) => {
mir::Rvalue::Ref(_, bk, place) => {
let mk_ref = move |tcx: TyCtxt<'tcx>, ty: Ty<'tcx>| {
tcx.mk_ref(
tcx.lifetimes.re_erased,
Expand All @@ -393,14 +393,14 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
self.codegen_place_to_pointer(bx, place, mk_ref)
}

mir::Rvalue::AddressOf(mutability, ref place) => {
mir::Rvalue::AddressOf(mutability, place) => {
let mk_ptr = move |tcx: TyCtxt<'tcx>, ty: Ty<'tcx>| {
tcx.mk_ptr(ty::TypeAndMut { ty, mutbl: mutability })
};
self.codegen_place_to_pointer(bx, place, mk_ptr)
}

mir::Rvalue::Len(ref place) => {
mir::Rvalue::Len(place) => {
let size = self.evaluate_array_len(&mut bx, place);
let operand = OperandRef {
val: OperandValue::Immediate(size),
Expand Down Expand Up @@ -537,7 +537,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
}
}

fn evaluate_array_len(&mut self, bx: &mut Bx, place: &mir::Place<'tcx>) -> Bx::Value {
fn evaluate_array_len(&mut self, bx: &mut Bx, place: mir::Place<'tcx>) -> Bx::Value {
// ZST are passed as operands and require special handling
// because codegen_place() panics if Local is operand.
if let Some(index) = place.as_local() {
Expand All @@ -557,7 +557,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
fn codegen_place_to_pointer(
&mut self,
mut bx: Bx,
place: &mir::Place<'tcx>,
place: mir::Place<'tcx>,
mk_ptr_ty: impl FnOnce(TyCtxt<'tcx>, Ty<'tcx>) -> Ty<'tcx>,
) -> (Bx, OperandRef<'tcx, Bx::Value>) {
let cg_place = self.codegen_place(&mut bx, place.as_ref());
Expand Down
2 changes: 2 additions & 0 deletions src/librustc_interface/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,8 @@ fn test_debugging_options_tracking_hash() {
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
opts.debugging_opts.dump_mir_graphviz = true;
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
opts.debugging_opts.dump_mir_dataflow = true;
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());

// Make sure changing a [TRACKED] option changes the hash
opts = reference.clone();
Expand Down
Loading