Skip to content

Commit fda6d37

Browse files
committed
Auto merge of #154455 - jhpratt:rollup-I3JcUWU, r=jhpratt
Rollup of 6 pull requests Successful merges: - #152457 (Pass -pg to linker when using -Zinstrument-mcount) - #154031 (Remove divergence check from check_expr_array) - #154418 (move many tests out of `ui/unsafe`) - #154441 (bootstrap: force a CI LLVM stamp bump) - #153675 (simd_add/sub/mul/neg: document overflow behavior) - #154430 (Create GPU target notification group)
2 parents e3691a5 + a16a4c3 commit fda6d37

48 files changed

Lines changed: 65 additions & 11 deletions

Some content is hidden

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

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2767,6 +2767,10 @@ fn add_order_independent_options(
27672767
cmd.pgo_gen();
27682768
}
27692769

2770+
if sess.opts.unstable_opts.instrument_mcount {
2771+
cmd.enable_profiling();
2772+
}
2773+
27702774
if sess.opts.cg.control_flow_guard != CFGuard::Disabled {
27712775
cmd.control_flow_guard();
27722776
}

compiler/rustc_codegen_ssa/src/back/linker.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ pub(crate) trait Linker {
352352
fn add_no_exec(&mut self) {}
353353
fn add_as_needed(&mut self) {}
354354
fn reset_per_library_state(&mut self) {}
355+
fn enable_profiling(&mut self) {}
355356
}
356357

357358
impl dyn Linker + '_ {
@@ -732,6 +733,19 @@ impl<'a> Linker for GccLinker<'a> {
732733
self.link_or_cc_args(&["-u", "__llvm_profile_runtime"]);
733734
}
734735

736+
fn enable_profiling(&mut self) {
737+
// This flag is also used when linking to choose target specific
738+
// libraries needed to enable profiling.
739+
self.cc_arg("-pg");
740+
// On windows-gnu targets, libgmon also needs to be linked, and this
741+
// requires readding libraries to satisfy its dependencies.
742+
if self.sess.target.is_like_windows {
743+
self.cc_arg("-lgmon");
744+
self.cc_arg("-lkernel32");
745+
self.cc_arg("-lmsvcrt");
746+
}
747+
}
748+
735749
fn control_flow_guard(&mut self) {}
736750

737751
fn ehcont_guard(&mut self) {}

compiler/rustc_hir_typeck/src/expr.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,14 +1660,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16601660
expr: &'tcx hir::Expr<'tcx>,
16611661
) -> Ty<'tcx> {
16621662
let element_ty = if !args.is_empty() {
1663-
// This shouldn't happen unless there's another error
1664-
// (e.g., never patterns in inappropriate contexts).
1665-
if self.diverges.get() != Diverges::Maybe {
1666-
self.dcx()
1667-
.struct_span_err(expr.span, "unexpected divergence state in checking array")
1668-
.delay_as_bug();
1669-
}
1670-
16711663
let coerce_to = expected
16721664
.to_option(self)
16731665
.and_then(|uty| {

compiler/rustc_target/src/spec/base/windows_gnu.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ pub(crate) fn opts() -> TargetOptions {
106106
// FIXME(davidtwco): Support Split DWARF on Windows GNU - may require LLVM changes to
107107
// output DWO, despite using DWARF, doesn't use ELF..
108108
supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Off]),
109+
mcount: "_mcount".into(),
109110
..Default::default()
110111
}
111112
}

compiler/rustc_target/src/spec/base/windows_gnullvm.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ pub(crate) fn opts() -> TargetOptions {
5353
// FIXME(davidtwco): Support Split DWARF on Windows GNU - may require LLVM changes to
5454
// output DWO, despite using DWARF, doesn't use ELF..
5555
supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Off]),
56+
mcount: "_mcount".into(),
5657
..Default::default()
5758
}
5859
}

library/core/src/intrinsics/simd.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,23 @@ pub const unsafe fn simd_splat<T, U>(value: U) -> T;
6262
/// Adds two simd vectors elementwise.
6363
///
6464
/// `T` must be a vector of integers or floats.
65+
/// For integers, wrapping arithmetic is used.
6566
#[rustc_intrinsic]
6667
#[rustc_nounwind]
6768
pub const unsafe fn simd_add<T>(x: T, y: T) -> T;
6869

6970
/// Subtracts `rhs` from `lhs` elementwise.
7071
///
7172
/// `T` must be a vector of integers or floats.
73+
/// For integers, wrapping arithmetic is used.
7274
#[rustc_intrinsic]
7375
#[rustc_nounwind]
7476
pub const unsafe fn simd_sub<T>(lhs: T, rhs: T) -> T;
7577

7678
/// Multiplies two simd vectors elementwise.
7779
///
7880
/// `T` must be a vector of integers or floats.
81+
/// For integers, wrapping arithmetic is used.
7982
#[rustc_intrinsic]
8083
#[rustc_nounwind]
8184
pub const unsafe fn simd_mul<T>(x: T, y: T) -> T;
@@ -233,8 +236,7 @@ pub const unsafe fn simd_as<T, U>(x: T) -> U;
233236
/// Negates a vector elementwise.
234237
///
235238
/// `T` must be a vector of integers or floats.
236-
///
237-
/// Rust panics for `-<int>::Min` due to overflow, but it is not UB with this intrinsic.
239+
/// For integers, wrapping arithmetic is used.
238240
#[rustc_intrinsic]
239241
#[rustc_nounwind]
240242
pub const unsafe fn simd_neg<T>(x: T) -> T;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Change this file to make users of the `download-ci-llvm` configuration download
22
a new version of LLVM from CI, even if the LLVM submodule hasn’t changed.
33

4-
Last change is for: https://github.com/rust-lang/rust/pull/153179
4+
Last change is for: https://github.com/rust-lang/rust/pull/151063
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
println!("Hello World!");
3+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// When building a binary instrumented with mcount, verify the
2+
// binary is linked with the correct crt to enable profiling.
3+
//
4+
//@ only-gnu
5+
//@ ignore-cross-compile
6+
7+
use run_make_support::{path, run, rustc};
8+
9+
fn main() {
10+
// Compile instrumentation enabled binary, and verify -pg is passed
11+
let link_args =
12+
rustc().input("main.rs").arg("-Zinstrument-mcount").print("link-args").run().stdout_utf8();
13+
assert!(link_args.contains("\"-pg\""));
14+
15+
// Run it, and verify gmon.out is created
16+
assert!(!path("gmon.out").exists());
17+
run("main");
18+
assert!(path("gmon.out").exists());
19+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//@ check-pass
2+
//@ edition: 2024
3+
4+
#![feature(never_patterns)]
5+
#![allow(incomplete_features)]
6+
#![allow(unreachable_code)]
7+
8+
fn main() {
9+
let _ = Some({
10+
return;
11+
})
12+
.map(|!| [1]);
13+
}

0 commit comments

Comments
 (0)