Skip to content

Commit 6ba33f5

Browse files
authored
Merge pull request #673 from rust-lang/sync_from_rust_2025_05_12
Sync from rust 2025/05/12
2 parents 2d794d4 + f38d6d0 commit 6ba33f5

File tree

11 files changed

+107
-34
lines changed

11 files changed

+107
-34
lines changed

.github/workflows/stdarch.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,8 @@ jobs:
101101
if: ${{ matrix.cargo_runner }}
102102
run: |
103103
# FIXME: these tests fail when the sysroot is compiled with LTO because of a missing symbol in proc-macro.
104-
# TODO: remove --skip test_mm512_stream_ps when stdarch is updated in rustc.
105104
# TODO: remove --skip test_tile_ when it's implemented.
106-
STDARCH_TEST_EVERYTHING=1 CHANNEL=release CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER="${{ matrix.cargo_runner }}" TARGET=x86_64-unknown-linux-gnu CG_RUSTFLAGS="-Ainternal_features --cfg stdarch_intel_sde" ./y.sh cargo test --manifest-path build/build_sysroot/sysroot_src/library/stdarch/Cargo.toml -- --skip rtm --skip tbm --skip sse4a --skip test_mm512_stream_ps --skip test_tile_
105+
STDARCH_TEST_SKIP_FUNCTION="xsave,xsaveopt,xsave64,xsaveopt64" STDARCH_TEST_EVERYTHING=1 CHANNEL=release CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER="${{ matrix.cargo_runner }}" TARGET=x86_64-unknown-linux-gnu CG_RUSTFLAGS="-Ainternal_features" ./y.sh cargo test --manifest-path build/build_sysroot/sysroot_src/library/stdarch/Cargo.toml -- --skip rtm --skip tbm --skip sse4a --skip test_tile_
107106
108107
# Summary job for the merge queue.
109108
# ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB!

rust-toolchain

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2025-04-26"
2+
channel = "nightly-2025-05-12"
33
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]

src/asm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ fn dummy_output_type<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, reg: InlineAsmRegCl
829829

830830
impl<'gcc, 'tcx> AsmCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
831831
fn codegen_global_asm(
832-
&self,
832+
&mut self,
833833
template: &[InlineAsmTemplatePiece],
834834
operands: &[GlobalAsmOperandRef<'tcx>],
835835
options: InlineAsmOptions,

src/attributes.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use rustc_attr_parsing::InlineAttr;
66
use rustc_attr_parsing::InstructionSetAttr;
77
#[cfg(feature = "master")]
88
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
9+
#[cfg(feature = "master")]
910
use rustc_middle::mir::TerminatorKind;
1011
use rustc_middle::ty;
1112

src/back/lto.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ use crate::{GccCodegenBackend, GccContext, SyncContext, to_gcc_opt_level};
4444

4545
pub fn crate_type_allows_lto(crate_type: CrateType) -> bool {
4646
match crate_type {
47-
CrateType::Executable | CrateType::Dylib | CrateType::Staticlib | CrateType::Cdylib => true,
47+
CrateType::Executable
48+
| CrateType::Dylib
49+
| CrateType::Staticlib
50+
| CrateType::Cdylib
51+
| CrateType::Sdylib => true,
4852
CrateType::Rlib | CrateType::ProcMacro => false,
4953
}
5054
}

src/base.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ pub fn compile_codegen_unit(
206206
let f128_type_supported = target_info.supports_target_dependent_type(CType::Float128);
207207
let u128_type_supported = target_info.supports_target_dependent_type(CType::UInt128t);
208208
// TODO: improve this to avoid passing that many arguments.
209-
let cx = CodegenCx::new(
209+
let mut cx = CodegenCx::new(
210210
&context,
211211
cgu,
212212
tcx,
@@ -223,8 +223,8 @@ pub fn compile_codegen_unit(
223223
}
224224

225225
// ... and now that we have everything pre-defined, fill out those definitions.
226-
for &(mono_item, _) in &mono_items {
227-
mono_item.define::<Builder<'_, '_, '_>>(&cx);
226+
for &(mono_item, item_data) in &mono_items {
227+
mono_item.define::<Builder<'_, '_, '_>>(&mut cx, item_data);
228228
}
229229

230230
// If this codegen unit contains the main function, also create the

src/builder.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ enum ExtremumOperation {
4545
Min,
4646
}
4747

48-
pub struct Builder<'a: 'gcc, 'gcc, 'tcx> {
48+
pub struct Builder<'a, 'gcc, 'tcx> {
4949
pub cx: &'a CodegenCx<'gcc, 'tcx>,
5050
pub block: Block<'gcc>,
5151
pub location: Option<Location<'gcc>>,
@@ -2471,7 +2471,6 @@ impl ToGccOrdering for AtomicOrdering {
24712471
use MemOrdering::*;
24722472

24732473
let ordering = match self {
2474-
AtomicOrdering::Unordered => __ATOMIC_RELAXED,
24752474
AtomicOrdering::Relaxed => __ATOMIC_RELAXED, // TODO(antoyo): check if that's the same.
24762475
AtomicOrdering::Acquire => __ATOMIC_ACQUIRE,
24772476
AtomicOrdering::Release => __ATOMIC_RELEASE,

src/gcc_util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
5555
)
5656
} else if let Some(feature) = feature.strip_prefix('-') {
5757
// FIXME: Why do we not remove implied features on "-" here?
58-
// We do the equivalent above in `target_features_cfg`.
58+
// We do the equivalent above in `target_config`.
5959
// See <https://github.com/rust-lang/rust/issues/134792>.
6060
all_rust_features.push((false, feature));
6161
} else if !feature.is_empty() && diagnostics {

src/intrinsic/mod.rs

+78-5
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ mod simd;
44
#[cfg(feature = "master")]
55
use std::iter;
66

7-
#[cfg(feature = "master")]
8-
use gccjit::FunctionType;
9-
use gccjit::{ComparisonOp, Function, RValue, ToRValue, Type, UnaryOp};
7+
use gccjit::{ComparisonOp, Function, FunctionType, RValue, ToRValue, Type, UnaryOp};
108
#[cfg(feature = "master")]
119
use rustc_abi::ExternAbi;
1210
use rustc_abi::{BackendRepr, HasDataLayout};
@@ -96,6 +94,72 @@ fn get_simple_intrinsic<'gcc, 'tcx>(
9694
Some(cx.context.get_builtin_function(gcc_name))
9795
}
9896

97+
// TODO(antoyo): We can probably remove these and use the fallback intrinsic implementation.
98+
fn get_simple_function<'gcc, 'tcx>(
99+
cx: &CodegenCx<'gcc, 'tcx>,
100+
name: Symbol,
101+
) -> Option<Function<'gcc>> {
102+
let (return_type, parameters, func_name) = match name {
103+
sym::minimumf32 => {
104+
let parameters = [
105+
cx.context.new_parameter(None, cx.float_type, "a"),
106+
cx.context.new_parameter(None, cx.float_type, "b"),
107+
];
108+
(cx.float_type, parameters, "fminimumf")
109+
}
110+
sym::minimumf64 => {
111+
let parameters = [
112+
cx.context.new_parameter(None, cx.double_type, "a"),
113+
cx.context.new_parameter(None, cx.double_type, "b"),
114+
];
115+
(cx.double_type, parameters, "fminimum")
116+
}
117+
sym::minimumf128 => {
118+
let f128_type = cx.type_f128();
119+
// GCC doesn't have the intrinsic we want so we use the compiler-builtins one
120+
// https://docs.rs/compiler_builtins/latest/compiler_builtins/math/full_availability/fn.fminimumf128.html
121+
let parameters = [
122+
cx.context.new_parameter(None, f128_type, "a"),
123+
cx.context.new_parameter(None, f128_type, "b"),
124+
];
125+
(f128_type, parameters, "fminimumf128")
126+
}
127+
sym::maximumf32 => {
128+
let parameters = [
129+
cx.context.new_parameter(None, cx.float_type, "a"),
130+
cx.context.new_parameter(None, cx.float_type, "b"),
131+
];
132+
(cx.float_type, parameters, "fmaximumf")
133+
}
134+
sym::maximumf64 => {
135+
let parameters = [
136+
cx.context.new_parameter(None, cx.double_type, "a"),
137+
cx.context.new_parameter(None, cx.double_type, "b"),
138+
];
139+
(cx.double_type, parameters, "fmaximum")
140+
}
141+
sym::maximumf128 => {
142+
let f128_type = cx.type_f128();
143+
// GCC doesn't have the intrinsic we want so we use the compiler-builtins one
144+
// https://docs.rs/compiler_builtins/latest/compiler_builtins/math/full_availability/fn.fmaximumf128.html
145+
let parameters = [
146+
cx.context.new_parameter(None, f128_type, "a"),
147+
cx.context.new_parameter(None, f128_type, "b"),
148+
];
149+
(f128_type, parameters, "fmaximumf128")
150+
}
151+
_ => return None,
152+
};
153+
Some(cx.context.new_function(
154+
None,
155+
FunctionType::Extern,
156+
return_type,
157+
&parameters,
158+
func_name,
159+
false,
160+
))
161+
}
162+
99163
impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
100164
fn codegen_intrinsic_call(
101165
&mut self,
@@ -124,14 +188,23 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc
124188
let result = PlaceRef::new_sized(llresult, fn_abi.ret.layout);
125189

126190
let simple = get_simple_intrinsic(self, name);
191+
let simple_func = get_simple_function(self, name);
127192

128193
// FIXME(tempdragon): Re-enable `clippy::suspicious_else_formatting` if the following issue is solved:
129194
// https://github.com/rust-lang/rust-clippy/issues/12497
130195
// and leave `else if use_integer_compare` to be placed "as is".
131196
#[allow(clippy::suspicious_else_formatting)]
132197
let value = match name {
133198
_ if simple.is_some() => {
134-
let func = simple.expect("simple function");
199+
let func = simple.expect("simple intrinsic function");
200+
self.cx.context.new_call(
201+
self.location,
202+
func,
203+
&args.iter().map(|arg| arg.immediate()).collect::<Vec<_>>(),
204+
)
205+
}
206+
_ if simple_func.is_some() => {
207+
let func = simple_func.expect("simple function");
135208
self.cx.context.new_call(
136209
self.location,
137210
func,
@@ -399,7 +472,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc
399472
}
400473

401474
// Fall back to default body
402-
_ => return Err(Instance::new(instance.def_id(), instance.args)),
475+
_ => return Err(Instance::new_raw(instance.def_id(), instance.args)),
403476
};
404477

405478
if !fn_abi.ret.is_ignore() {

src/lib.rs

+14-8
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ use rustc_codegen_ssa::back::write::{
102102
};
103103
use rustc_codegen_ssa::base::codegen_crate;
104104
use rustc_codegen_ssa::traits::{CodegenBackend, ExtraBackendMethods, WriteBackendMethods};
105-
use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleCodegen};
105+
use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleCodegen, TargetConfig};
106106
use rustc_data_structures::fx::FxIndexMap;
107107
use rustc_data_structures::sync::IntoDynSyncSend;
108108
use rustc_errors::DiagCtxtHandle;
@@ -260,8 +260,8 @@ impl CodegenBackend for GccCodegenBackend {
260260
.join(sess)
261261
}
262262

263-
fn target_features_cfg(&self, sess: &Session) -> (Vec<Symbol>, Vec<Symbol>) {
264-
target_features_cfg(sess, &self.target_info)
263+
fn target_config(&self, sess: &Session) -> TargetConfig {
264+
target_config(sess, &self.target_info)
265265
}
266266
}
267267

@@ -485,10 +485,7 @@ fn to_gcc_opt_level(optlevel: Option<OptLevel>) -> OptimizationLevel {
485485
}
486486

487487
/// Returns the features that should be set in `cfg(target_feature)`.
488-
fn target_features_cfg(
489-
sess: &Session,
490-
target_info: &LockedTargetInfo,
491-
) -> (Vec<Symbol>, Vec<Symbol>) {
488+
fn target_config(sess: &Session, target_info: &LockedTargetInfo) -> TargetConfig {
492489
// TODO(antoyo): use global_gcc_features.
493490
let f = |allow_unstable| {
494491
sess.target
@@ -523,5 +520,14 @@ fn target_features_cfg(
523520

524521
let target_features = f(false);
525522
let unstable_target_features = f(true);
526-
(target_features, unstable_target_features)
523+
524+
TargetConfig {
525+
target_features,
526+
unstable_target_features,
527+
// There are no known bugs with GCC support for f16 or f128
528+
has_reliable_f16: true,
529+
has_reliable_f16_math: true,
530+
has_reliable_f128: true,
531+
has_reliable_f128_math: true,
532+
}
527533
}

tests/failing-ui-tests.txt

+1-10
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ tests/ui/sepcomp/sepcomp-fns-backwards.rs
1010
tests/ui/sepcomp/sepcomp-fns.rs
1111
tests/ui/sepcomp/sepcomp-statics.rs
1212
tests/ui/asm/x86_64/may_unwind.rs
13-
tests/ui/catch-unwind-bang.rs
13+
tests/ui/panics/catch-unwind-bang.rs
1414
tests/ui/drop/dynamic-drop-async.rs
1515
tests/ui/cfg/cfg-panic-abort.rs
1616
tests/ui/drop/repeat-drop.rs
@@ -94,23 +94,14 @@ tests/ui/simd/intrinsic/generic-as.rs
9494
tests/ui/backtrace/backtrace.rs
9595
tests/ui/lifetimes/tail-expr-lock-poisoning.rs
9696
tests/ui/runtime/rt-explody-panic-payloads.rs
97-
tests/ui/codegen/equal-pointers-unequal/as-cast/function.rs
98-
tests/ui/codegen/equal-pointers-unequal/as-cast/basic.rs
9997
tests/ui/codegen/equal-pointers-unequal/as-cast/inline1.rs
100-
tests/ui/codegen/equal-pointers-unequal/as-cast/print.rs
10198
tests/ui/codegen/equal-pointers-unequal/as-cast/inline2.rs
10299
tests/ui/codegen/equal-pointers-unequal/as-cast/segfault.rs
103-
tests/ui/codegen/equal-pointers-unequal/exposed-provenance/function.rs
104-
tests/ui/codegen/equal-pointers-unequal/exposed-provenance/basic.rs
105100
tests/ui/codegen/equal-pointers-unequal/as-cast/zero.rs
106101
tests/ui/codegen/equal-pointers-unequal/exposed-provenance/inline1.rs
107-
tests/ui/codegen/equal-pointers-unequal/exposed-provenance/print.rs
108102
tests/ui/codegen/equal-pointers-unequal/exposed-provenance/inline2.rs
109103
tests/ui/codegen/equal-pointers-unequal/exposed-provenance/segfault.rs
110104
tests/ui/codegen/equal-pointers-unequal/exposed-provenance/zero.rs
111-
tests/ui/codegen/equal-pointers-unequal/strict-provenance/basic.rs
112-
tests/ui/codegen/equal-pointers-unequal/strict-provenance/function.rs
113-
tests/ui/codegen/equal-pointers-unequal/strict-provenance/print.rs
114105
tests/ui/codegen/equal-pointers-unequal/strict-provenance/inline1.rs
115106
tests/ui/codegen/equal-pointers-unequal/strict-provenance/inline2.rs
116107
tests/ui/codegen/equal-pointers-unequal/strict-provenance/segfault.rs

0 commit comments

Comments
 (0)