Skip to content

Commit 235938d

Browse files
committed
Auto merge of #70653 - Centril:rollup-vh5x5e5, r=Centril
Rollup of 6 pull requests Successful merges: - #70511 (Add `-Z dump-mir-dataflow` flag for dumping dataflow results visualization) - #70522 (Improve error messages for raw strings (#60762)) - #70547 (Add `can_unwind` field to `FnAbi`) - #70591 (Ensure LLVM is in the link path for "fulldeps" tests) - #70627 (Use place directly its copy) - #70652 (Add git repo address to unstable book) Failed merges: - #70634 (Remove some reexports in `rustc_middle`) r? @ghost
2 parents 99009bf + c1419b4 commit 235938d

File tree

92 files changed

+852
-514
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+852
-514
lines changed

src/bootstrap/test.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use crate::flags::Subcommand;
2121
use crate::native;
2222
use crate::tool::{self, SourceType, Tool};
2323
use crate::toolstate::ToolState;
24-
use crate::util::{self, dylib_path, dylib_path_var};
24+
use crate::util::{self, add_link_lib_path, dylib_path, dylib_path_var};
2525
use crate::Crate as CargoCrate;
2626
use crate::{envify, DocTests, GitRepo, Mode};
2727

@@ -1178,6 +1178,15 @@ impl Step for Compiletest {
11781178
cmd.arg("--system-llvm");
11791179
}
11801180

1181+
// Tests that use compiler libraries may inherit the `-lLLVM` link
1182+
// requirement, but the `-L` library path is not propagated across
1183+
// separate compilations. We can add LLVM's library path to the
1184+
// platform-specific environment variable as a workaround.
1185+
if !builder.config.dry_run && suite.ends_with("fulldeps") {
1186+
let llvm_libdir = output(Command::new(&llvm_config).arg("--libdir"));
1187+
add_link_lib_path(vec![llvm_libdir.trim().into()], &mut cmd);
1188+
}
1189+
11811190
// Only pass correct values for these flags for the `run-make` suite as it
11821191
// requires that a C++ compiler was configured which isn't always the case.
11831192
if !builder.config.dry_run && suite == "run-make-fulldeps" {

src/doc/unstable-book/book.toml

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[book]
22
title = "The Rust Unstable Book"
33
author = "The Rust Community"
4+
5+
[output.html]
6+
git-repository-url = "https://github.com/rust-lang/rust/tree/master/src/doc/unstable-book"

src/librustc_codegen_llvm/abi.rs

+7
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,11 @@ impl<'tcx> FnAbiLlvmExt<'tcx> for FnAbi<'tcx, Ty<'tcx>> {
396396
llvm::Attribute::NoReturn.apply_llfn(llvm::AttributePlace::Function, llfn);
397397
}
398398

399+
// FIXME(eddyb, wesleywiser): apply this to callsites as well?
400+
if !self.can_unwind {
401+
llvm::Attribute::NoUnwind.apply_llfn(llvm::AttributePlace::Function, llfn);
402+
}
403+
399404
let mut i = 0;
400405
let mut apply = |attrs: &ArgAttributes, ty: Option<&Type>| {
401406
attrs.apply_llfn(llvm::AttributePlace::Argument(i), llfn, ty);
@@ -431,6 +436,8 @@ impl<'tcx> FnAbiLlvmExt<'tcx> for FnAbi<'tcx, Ty<'tcx>> {
431436
}
432437

433438
fn apply_attrs_callsite(&self, bx: &mut Builder<'a, 'll, 'tcx>, callsite: &'ll Value) {
439+
// FIXME(wesleywiser, eddyb): We should apply `nounwind` and `noreturn` as appropriate to this callsite.
440+
434441
let mut i = 0;
435442
let mut apply = |attrs: &ArgAttributes, ty: Option<&Type>| {
436443
attrs.apply_callsite(llvm::AttributePlace::Argument(i), callsite, ty);

src/librustc_codegen_llvm/attributes.rs

+2-56
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,10 @@ use rustc_hir::def_id::{DefId, LOCAL_CRATE};
1010
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
1111
use rustc_middle::ty::layout::HasTyCtxt;
1212
use rustc_middle::ty::query::Providers;
13-
use rustc_middle::ty::{self, Ty, TyCtxt};
13+
use rustc_middle::ty::{self, TyCtxt};
1414
use rustc_session::config::{OptLevel, Sanitizer};
1515
use rustc_session::Session;
16-
use rustc_target::abi::call::Conv;
17-
use rustc_target::spec::PanicStrategy;
1816

19-
use crate::abi::FnAbi;
2017
use crate::attributes;
2118
use crate::llvm::AttributePlace::Function;
2219
use crate::llvm::{self, Attribute};
@@ -77,12 +74,6 @@ pub fn emit_uwtable(val: &'ll Value, emit: bool) {
7774
Attribute::UWTable.toggle_llfn(Function, val, emit);
7875
}
7976

80-
/// Tell LLVM whether the function can or cannot unwind.
81-
#[inline]
82-
fn unwind(val: &'ll Value, can_unwind: bool) {
83-
Attribute::NoUnwind.toggle_llfn(Function, val, !can_unwind);
84-
}
85-
8677
/// Tell LLVM if this function should be 'naked', i.e., skip the epilogue and prologue.
8778
#[inline]
8879
fn naked(val: &'ll Value, is_naked: bool) {
@@ -246,12 +237,7 @@ pub(crate) fn default_optimisation_attrs(sess: &Session, llfn: &'ll Value) {
246237

247238
/// Composite function which sets LLVM attributes for function depending on its AST (`#[attribute]`)
248239
/// attributes.
249-
pub fn from_fn_attrs(
250-
cx: &CodegenCx<'ll, 'tcx>,
251-
llfn: &'ll Value,
252-
instance: ty::Instance<'tcx>,
253-
fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
254-
) {
240+
pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty::Instance<'tcx>) {
255241
let codegen_fn_attrs = cx.tcx.codegen_fn_attrs(instance.def_id());
256242

257243
match codegen_fn_attrs.optimize {
@@ -315,46 +301,6 @@ pub fn from_fn_attrs(
315301
}
316302
sanitize(cx, codegen_fn_attrs.flags, llfn);
317303

318-
unwind(
319-
llfn,
320-
if cx.tcx.sess.panic_strategy() != PanicStrategy::Unwind {
321-
// In panic=abort mode we assume nothing can unwind anywhere, so
322-
// optimize based on this!
323-
false
324-
} else if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::UNWIND) {
325-
// If a specific #[unwind] attribute is present, use that.
326-
true
327-
} else if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::RUSTC_ALLOCATOR_NOUNWIND) {
328-
// Special attribute for allocator functions, which can't unwind.
329-
false
330-
} else {
331-
if fn_abi.conv == Conv::Rust {
332-
// Any Rust method (or `extern "Rust" fn` or `extern
333-
// "rust-call" fn`) is explicitly allowed to unwind
334-
// (unless it has no-unwind attribute, handled above).
335-
true
336-
} else {
337-
// Anything else is either:
338-
//
339-
// 1. A foreign item using a non-Rust ABI (like `extern "C" { fn foo(); }`), or
340-
//
341-
// 2. A Rust item using a non-Rust ABI (like `extern "C" fn foo() { ... }`).
342-
//
343-
// Foreign items (case 1) are assumed to not unwind; it is
344-
// UB otherwise. (At least for now; see also
345-
// rust-lang/rust#63909 and Rust RFC 2753.)
346-
//
347-
// Items defined in Rust with non-Rust ABIs (case 2) are also
348-
// not supposed to unwind. Whether this should be enforced
349-
// (versus stating it is UB) and *how* it would be enforced
350-
// is currently under discussion; see rust-lang/rust#58794.
351-
//
352-
// In either case, we mark item as explicitly nounwind.
353-
false
354-
}
355-
},
356-
);
357-
358304
// Always annotate functions with the target-cpu they are compiled for.
359305
// Without this, ThinLTO won't inline Rust functions into Clang generated
360306
// functions (because Clang annotates functions this way too).

src/librustc_codegen_llvm/callee.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub fn get_fn(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'tcx>) -> &'ll Value
7878
let llfn = cx.declare_fn(&sym, &fn_abi);
7979
debug!("get_fn: not casting pointer!");
8080

81-
attributes::from_fn_attrs(cx, llfn, instance, &fn_abi);
81+
attributes::from_fn_attrs(cx, llfn, instance);
8282

8383
let instance_def_id = instance.def_id();
8484

src/librustc_codegen_llvm/mono_item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl PreDefineMethods<'tcx> for CodegenCx<'ll, 'tcx> {
7777

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

80-
attributes::from_fn_attrs(self, lldecl, instance, &fn_abi);
80+
attributes::from_fn_attrs(self, lldecl, instance);
8181

8282
self.instances.borrow_mut().insert(instance, lldecl);
8383
}

src/librustc_codegen_ssa/mir/block.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
299299
&mut self,
300300
helper: TerminatorCodegenHelper<'tcx>,
301301
mut bx: Bx,
302-
location: &mir::Place<'tcx>,
302+
location: mir::Place<'tcx>,
303303
target: mir::BasicBlock,
304304
unwind: Option<mir::BasicBlock>,
305305
) {
@@ -580,7 +580,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
580580

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

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

876-
mir::TerminatorKind::Drop { ref location, target, unwind } => {
876+
mir::TerminatorKind::Drop { location, target, unwind } => {
877877
self.codegen_drop_terminator(helper, bx, location, target, unwind);
878878
}
879879

@@ -1123,7 +1123,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
11231123
fn make_return_dest(
11241124
&mut self,
11251125
bx: &mut Bx,
1126-
dest: &mir::Place<'tcx>,
1126+
dest: mir::Place<'tcx>,
11271127
fn_ret: &ArgAbi<'tcx, Ty<'tcx>>,
11281128
llargs: &mut Vec<Bx::Value>,
11291129
is_intrinsic: bool,
@@ -1184,7 +1184,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
11841184
}
11851185
}
11861186

1187-
fn codegen_transmute(&mut self, bx: &mut Bx, src: &mir::Operand<'tcx>, dst: &mir::Place<'tcx>) {
1187+
fn codegen_transmute(&mut self, bx: &mut Bx, src: &mir::Operand<'tcx>, dst: mir::Place<'tcx>) {
11881188
if let Some(index) = dst.as_local() {
11891189
match self.locals[index] {
11901190
LocalRef::Place(place) => self.codegen_transmute_into(bx, src, place),

src/librustc_codegen_ssa/mir/rvalue.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
383383
(bx, OperandRef { val, layout: cast })
384384
}
385385

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

396-
mir::Rvalue::AddressOf(mutability, ref place) => {
396+
mir::Rvalue::AddressOf(mutability, place) => {
397397
let mk_ptr = move |tcx: TyCtxt<'tcx>, ty: Ty<'tcx>| {
398398
tcx.mk_ptr(ty::TypeAndMut { ty, mutbl: mutability })
399399
};
400400
self.codegen_place_to_pointer(bx, place, mk_ptr)
401401
}
402402

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

540-
fn evaluate_array_len(&mut self, bx: &mut Bx, place: &mir::Place<'tcx>) -> Bx::Value {
540+
fn evaluate_array_len(&mut self, bx: &mut Bx, place: mir::Place<'tcx>) -> Bx::Value {
541541
// ZST are passed as operands and require special handling
542542
// because codegen_place() panics if Local is operand.
543543
if let Some(index) = place.as_local() {
@@ -557,7 +557,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
557557
fn codegen_place_to_pointer(
558558
&mut self,
559559
mut bx: Bx,
560-
place: &mir::Place<'tcx>,
560+
place: mir::Place<'tcx>,
561561
mk_ptr_ty: impl FnOnce(TyCtxt<'tcx>, Ty<'tcx>) -> Ty<'tcx>,
562562
) -> (Bx, OperandRef<'tcx, Bx::Value>) {
563563
let cg_place = self.codegen_place(&mut bx, place.as_ref());

src/librustc_interface/tests.rs

+2
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,8 @@ fn test_debugging_options_tracking_hash() {
562562
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
563563
opts.debugging_opts.dump_mir_graphviz = true;
564564
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
565+
opts.debugging_opts.dump_mir_dataflow = true;
566+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
565567

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

0 commit comments

Comments
 (0)