Skip to content

Commit 0decdac

Browse files
committed
Auto merge of rust-lang#121914 - Nadrieril:rollup-ol98ncg, r=Nadrieril
Rollup of 5 pull requests Successful merges: - rust-lang#120761 (Add initial support for DataFlowSanitizer) - rust-lang#121622 (Preserve same vtable pointer when cloning raw waker, to fix Waker::will_wake) - rust-lang#121716 (match lowering: Lower bindings in a predictable order) - rust-lang#121731 (Now that inlining, mir validation and const eval all use reveal-all, we won't be constraining hidden types here anymore) - rust-lang#121841 (`f16` and `f128` step 2: intrinsics) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 5119208 + 4c65eef commit 0decdac

File tree

52 files changed

+1156
-144
lines changed

Some content is hidden

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

52 files changed

+1156
-144
lines changed

compiler/rustc_ast/src/ast.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1920,22 +1920,28 @@ pub struct FnSig {
19201920
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
19211921
#[derive(Encodable, Decodable, HashStable_Generic)]
19221922
pub enum FloatTy {
1923+
F16,
19231924
F32,
19241925
F64,
1926+
F128,
19251927
}
19261928

19271929
impl FloatTy {
19281930
pub fn name_str(self) -> &'static str {
19291931
match self {
1932+
FloatTy::F16 => "f16",
19301933
FloatTy::F32 => "f32",
19311934
FloatTy::F64 => "f64",
1935+
FloatTy::F128 => "f128",
19321936
}
19331937
}
19341938

19351939
pub fn name(self) -> Symbol {
19361940
match self {
1941+
FloatTy::F16 => sym::f16,
19371942
FloatTy::F32 => sym::f32,
19381943
FloatTy::F64 => sym::f64,
1944+
FloatTy::F128 => sym::f128,
19391945
}
19401946
}
19411947
}

compiler/rustc_codegen_llvm/src/back/write.rs

+10
Original file line numberDiff line numberDiff line change
@@ -519,12 +519,22 @@ pub(crate) unsafe fn llvm_optimize(
519519
let pgo_sample_use_path = get_pgo_sample_use_path(config);
520520
let is_lto = opt_stage == llvm::OptStage::ThinLTO || opt_stage == llvm::OptStage::FatLTO;
521521
let instr_profile_output_path = get_instr_profile_output_path(config);
522+
let sanitize_dataflow_abilist: Vec<_> = config
523+
.sanitizer_dataflow_abilist
524+
.iter()
525+
.map(|file| CString::new(file.as_str()).unwrap())
526+
.collect();
527+
let sanitize_dataflow_abilist_ptrs: Vec<_> =
528+
sanitize_dataflow_abilist.iter().map(|file| file.as_ptr()).collect();
522529
// Sanitizer instrumentation is only inserted during the pre-link optimization stage.
523530
let sanitizer_options = if !is_lto {
524531
Some(llvm::SanitizerOptions {
525532
sanitize_address: config.sanitizer.contains(SanitizerSet::ADDRESS),
526533
sanitize_address_recover: config.sanitizer_recover.contains(SanitizerSet::ADDRESS),
527534
sanitize_cfi: config.sanitizer.contains(SanitizerSet::CFI),
535+
sanitize_dataflow: config.sanitizer.contains(SanitizerSet::DATAFLOW),
536+
sanitize_dataflow_abilist: sanitize_dataflow_abilist_ptrs.as_ptr(),
537+
sanitize_dataflow_abilist_len: sanitize_dataflow_abilist_ptrs.len(),
528538
sanitize_kcfi: config.sanitizer.contains(SanitizerSet::KCFI),
529539
sanitize_memory: config.sanitizer.contains(SanitizerSet::MEMORY),
530540
sanitize_memory_recover: config.sanitizer_recover.contains(SanitizerSet::MEMORY),

compiler/rustc_codegen_llvm/src/context.rs

+48
Original file line numberDiff line numberDiff line change
@@ -685,8 +685,10 @@ impl<'ll> CodegenCx<'ll, '_> {
685685
let t_i64 = self.type_i64();
686686
let t_i128 = self.type_i128();
687687
let t_isize = self.type_isize();
688+
let t_f16 = self.type_f16();
688689
let t_f32 = self.type_f32();
689690
let t_f64 = self.type_f64();
691+
let t_f128 = self.type_f128();
690692
let t_metadata = self.type_metadata();
691693
let t_token = self.type_token();
692694

@@ -728,69 +730,115 @@ impl<'ll> CodegenCx<'ll, '_> {
728730
ifn!("llvm.debugtrap", fn() -> void);
729731
ifn!("llvm.frameaddress", fn(t_i32) -> ptr);
730732

733+
ifn!("llvm.powi.f16", fn(t_f16, t_i32) -> t_f16);
731734
ifn!("llvm.powi.f32", fn(t_f32, t_i32) -> t_f32);
732735
ifn!("llvm.powi.f64", fn(t_f64, t_i32) -> t_f64);
736+
ifn!("llvm.powi.f128", fn(t_f128, t_i32) -> t_f128);
733737

738+
ifn!("llvm.pow.f16", fn(t_f16, t_f16) -> t_f16);
734739
ifn!("llvm.pow.f32", fn(t_f32, t_f32) -> t_f32);
735740
ifn!("llvm.pow.f64", fn(t_f64, t_f64) -> t_f64);
741+
ifn!("llvm.pow.f128", fn(t_f128, t_f128) -> t_f128);
736742

743+
ifn!("llvm.sqrt.f16", fn(t_f16) -> t_f16);
737744
ifn!("llvm.sqrt.f32", fn(t_f32) -> t_f32);
738745
ifn!("llvm.sqrt.f64", fn(t_f64) -> t_f64);
746+
ifn!("llvm.sqrt.f128", fn(t_f128) -> t_f128);
739747

748+
ifn!("llvm.sin.f16", fn(t_f16) -> t_f16);
740749
ifn!("llvm.sin.f32", fn(t_f32) -> t_f32);
741750
ifn!("llvm.sin.f64", fn(t_f64) -> t_f64);
751+
ifn!("llvm.sin.f128", fn(t_f128) -> t_f128);
742752

753+
ifn!("llvm.cos.f16", fn(t_f16) -> t_f16);
743754
ifn!("llvm.cos.f32", fn(t_f32) -> t_f32);
744755
ifn!("llvm.cos.f64", fn(t_f64) -> t_f64);
756+
ifn!("llvm.cos.f128", fn(t_f128) -> t_f128);
745757

758+
ifn!("llvm.exp.f16", fn(t_f16) -> t_f16);
746759
ifn!("llvm.exp.f32", fn(t_f32) -> t_f32);
747760
ifn!("llvm.exp.f64", fn(t_f64) -> t_f64);
761+
ifn!("llvm.exp.f128", fn(t_f128) -> t_f128);
748762

763+
ifn!("llvm.exp2.f16", fn(t_f16) -> t_f16);
749764
ifn!("llvm.exp2.f32", fn(t_f32) -> t_f32);
750765
ifn!("llvm.exp2.f64", fn(t_f64) -> t_f64);
766+
ifn!("llvm.exp2.f128", fn(t_f128) -> t_f128);
751767

768+
ifn!("llvm.log.f16", fn(t_f16) -> t_f16);
752769
ifn!("llvm.log.f32", fn(t_f32) -> t_f32);
753770
ifn!("llvm.log.f64", fn(t_f64) -> t_f64);
771+
ifn!("llvm.log.f128", fn(t_f128) -> t_f128);
754772

773+
ifn!("llvm.log10.f16", fn(t_f16) -> t_f16);
755774
ifn!("llvm.log10.f32", fn(t_f32) -> t_f32);
756775
ifn!("llvm.log10.f64", fn(t_f64) -> t_f64);
776+
ifn!("llvm.log10.f128", fn(t_f128) -> t_f128);
757777

778+
ifn!("llvm.log2.f16", fn(t_f16) -> t_f16);
758779
ifn!("llvm.log2.f32", fn(t_f32) -> t_f32);
759780
ifn!("llvm.log2.f64", fn(t_f64) -> t_f64);
781+
ifn!("llvm.log2.f128", fn(t_f128) -> t_f128);
760782

783+
ifn!("llvm.fma.f16", fn(t_f16, t_f16, t_f16) -> t_f16);
761784
ifn!("llvm.fma.f32", fn(t_f32, t_f32, t_f32) -> t_f32);
762785
ifn!("llvm.fma.f64", fn(t_f64, t_f64, t_f64) -> t_f64);
786+
ifn!("llvm.fma.f128", fn(t_f128, t_f128, t_f128) -> t_f128);
763787

788+
ifn!("llvm.fabs.f16", fn(t_f16) -> t_f16);
764789
ifn!("llvm.fabs.f32", fn(t_f32) -> t_f32);
765790
ifn!("llvm.fabs.f64", fn(t_f64) -> t_f64);
791+
ifn!("llvm.fabs.f128", fn(t_f128) -> t_f128);
766792

793+
ifn!("llvm.minnum.f16", fn(t_f16, t_f16) -> t_f16);
767794
ifn!("llvm.minnum.f32", fn(t_f32, t_f32) -> t_f32);
768795
ifn!("llvm.minnum.f64", fn(t_f64, t_f64) -> t_f64);
796+
ifn!("llvm.minnum.f128", fn(t_f128, t_f128) -> t_f128);
797+
798+
ifn!("llvm.maxnum.f16", fn(t_f16, t_f16) -> t_f16);
769799
ifn!("llvm.maxnum.f32", fn(t_f32, t_f32) -> t_f32);
770800
ifn!("llvm.maxnum.f64", fn(t_f64, t_f64) -> t_f64);
801+
ifn!("llvm.maxnum.f128", fn(t_f128, t_f128) -> t_f128);
771802

803+
ifn!("llvm.floor.f16", fn(t_f16) -> t_f16);
772804
ifn!("llvm.floor.f32", fn(t_f32) -> t_f32);
773805
ifn!("llvm.floor.f64", fn(t_f64) -> t_f64);
806+
ifn!("llvm.floor.f128", fn(t_f128) -> t_f128);
774807

808+
ifn!("llvm.ceil.f16", fn(t_f16) -> t_f16);
775809
ifn!("llvm.ceil.f32", fn(t_f32) -> t_f32);
776810
ifn!("llvm.ceil.f64", fn(t_f64) -> t_f64);
811+
ifn!("llvm.ceil.f128", fn(t_f128) -> t_f128);
777812

813+
ifn!("llvm.trunc.f16", fn(t_f16) -> t_f16);
778814
ifn!("llvm.trunc.f32", fn(t_f32) -> t_f32);
779815
ifn!("llvm.trunc.f64", fn(t_f64) -> t_f64);
816+
ifn!("llvm.trunc.f128", fn(t_f128) -> t_f128);
780817

818+
ifn!("llvm.copysign.f16", fn(t_f16, t_f16) -> t_f16);
781819
ifn!("llvm.copysign.f32", fn(t_f32, t_f32) -> t_f32);
782820
ifn!("llvm.copysign.f64", fn(t_f64, t_f64) -> t_f64);
821+
ifn!("llvm.copysign.f128", fn(t_f128, t_f128) -> t_f128);
783822

823+
ifn!("llvm.round.f16", fn(t_f16) -> t_f16);
784824
ifn!("llvm.round.f32", fn(t_f32) -> t_f32);
785825
ifn!("llvm.round.f64", fn(t_f64) -> t_f64);
826+
ifn!("llvm.round.f128", fn(t_f128) -> t_f128);
786827

828+
ifn!("llvm.roundeven.f16", fn(t_f16) -> t_f16);
787829
ifn!("llvm.roundeven.f32", fn(t_f32) -> t_f32);
788830
ifn!("llvm.roundeven.f64", fn(t_f64) -> t_f64);
831+
ifn!("llvm.roundeven.f128", fn(t_f128) -> t_f128);
789832

833+
ifn!("llvm.rint.f16", fn(t_f16) -> t_f16);
790834
ifn!("llvm.rint.f32", fn(t_f32) -> t_f32);
791835
ifn!("llvm.rint.f64", fn(t_f64) -> t_f64);
836+
ifn!("llvm.rint.f128", fn(t_f128) -> t_f128);
837+
838+
ifn!("llvm.nearbyint.f16", fn(t_f16) -> t_f16);
792839
ifn!("llvm.nearbyint.f32", fn(t_f32) -> t_f32);
793840
ifn!("llvm.nearbyint.f64", fn(t_f64) -> t_f64);
841+
ifn!("llvm.nearbyint.f128", fn(t_f128) -> t_f128);
794842

795843
ifn!("llvm.ctpop.i8", fn(t_i8) -> t_i8);
796844
ifn!("llvm.ctpop.i16", fn(t_i16) -> t_i16);

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ impl MsvcBasicName for ty::UintTy {
695695

696696
impl MsvcBasicName for ty::FloatTy {
697697
fn msvc_basic_name(self) -> &'static str {
698-
// FIXME: f16 and f128 have no MSVE representation. We could improve the debuginfo.
698+
// FIXME: f16 and f128 have no MSVC representation. We could improve the debuginfo.
699699
// See: <https://github.com/rust-lang/rust/pull/114607/files#r1454683264>
700700
match self {
701701
ty::FloatTy::F16 => "half",

compiler/rustc_codegen_llvm/src/intrinsic.rs

+67
Original file line numberDiff line numberDiff line change
@@ -28,51 +28,118 @@ fn get_simple_intrinsic<'ll>(
2828
name: Symbol,
2929
) -> Option<(&'ll Type, &'ll Value)> {
3030
let llvm_name = match name {
31+
sym::sqrtf16 => "llvm.sqrt.f16",
3132
sym::sqrtf32 => "llvm.sqrt.f32",
3233
sym::sqrtf64 => "llvm.sqrt.f64",
34+
sym::sqrtf128 => "llvm.sqrt.f128",
35+
36+
sym::powif16 => "llvm.powi.f16",
3337
sym::powif32 => "llvm.powi.f32",
3438
sym::powif64 => "llvm.powi.f64",
39+
sym::powif128 => "llvm.powi.f128",
40+
41+
sym::sinf16 => "llvm.sin.f16",
3542
sym::sinf32 => "llvm.sin.f32",
3643
sym::sinf64 => "llvm.sin.f64",
44+
sym::sinf128 => "llvm.sin.f128",
45+
46+
sym::cosf16 => "llvm.cos.f16",
3747
sym::cosf32 => "llvm.cos.f32",
3848
sym::cosf64 => "llvm.cos.f64",
49+
sym::cosf128 => "llvm.cos.f128",
50+
51+
sym::powf16 => "llvm.pow.f16",
3952
sym::powf32 => "llvm.pow.f32",
4053
sym::powf64 => "llvm.pow.f64",
54+
sym::powf128 => "llvm.pow.f128",
55+
56+
sym::expf16 => "llvm.exp.f16",
4157
sym::expf32 => "llvm.exp.f32",
4258
sym::expf64 => "llvm.exp.f64",
59+
sym::expf128 => "llvm.exp.f128",
60+
61+
sym::exp2f16 => "llvm.exp2.f16",
4362
sym::exp2f32 => "llvm.exp2.f32",
4463
sym::exp2f64 => "llvm.exp2.f64",
64+
sym::exp2f128 => "llvm.exp2.f128",
65+
66+
sym::logf16 => "llvm.log.f16",
4567
sym::logf32 => "llvm.log.f32",
4668
sym::logf64 => "llvm.log.f64",
69+
sym::logf128 => "llvm.log.f128",
70+
71+
sym::log10f16 => "llvm.log10.f16",
4772
sym::log10f32 => "llvm.log10.f32",
4873
sym::log10f64 => "llvm.log10.f64",
74+
sym::log10f128 => "llvm.log10.f128",
75+
76+
sym::log2f16 => "llvm.log2.f16",
4977
sym::log2f32 => "llvm.log2.f32",
5078
sym::log2f64 => "llvm.log2.f64",
79+
sym::log2f128 => "llvm.log2.f128",
80+
81+
sym::fmaf16 => "llvm.fma.f16",
5182
sym::fmaf32 => "llvm.fma.f32",
5283
sym::fmaf64 => "llvm.fma.f64",
84+
sym::fmaf128 => "llvm.fma.f128",
85+
86+
sym::fabsf16 => "llvm.fabs.f16",
5387
sym::fabsf32 => "llvm.fabs.f32",
5488
sym::fabsf64 => "llvm.fabs.f64",
89+
sym::fabsf128 => "llvm.fabs.f128",
90+
91+
sym::minnumf16 => "llvm.minnum.f16",
5592
sym::minnumf32 => "llvm.minnum.f32",
5693
sym::minnumf64 => "llvm.minnum.f64",
94+
sym::minnumf128 => "llvm.minnum.f128",
95+
96+
sym::maxnumf16 => "llvm.maxnum.f16",
5797
sym::maxnumf32 => "llvm.maxnum.f32",
5898
sym::maxnumf64 => "llvm.maxnum.f64",
99+
sym::maxnumf128 => "llvm.maxnum.f128",
100+
101+
sym::copysignf16 => "llvm.copysign.f16",
59102
sym::copysignf32 => "llvm.copysign.f32",
60103
sym::copysignf64 => "llvm.copysign.f64",
104+
sym::copysignf128 => "llvm.copysign.f128",
105+
106+
sym::floorf16 => "llvm.floor.f16",
61107
sym::floorf32 => "llvm.floor.f32",
62108
sym::floorf64 => "llvm.floor.f64",
109+
sym::floorf128 => "llvm.floor.f128",
110+
111+
sym::ceilf16 => "llvm.ceil.f16",
63112
sym::ceilf32 => "llvm.ceil.f32",
64113
sym::ceilf64 => "llvm.ceil.f64",
114+
sym::ceilf128 => "llvm.ceil.f128",
115+
116+
sym::truncf16 => "llvm.trunc.f16",
65117
sym::truncf32 => "llvm.trunc.f32",
66118
sym::truncf64 => "llvm.trunc.f64",
119+
sym::truncf128 => "llvm.trunc.f128",
120+
121+
sym::rintf16 => "llvm.rint.f16",
67122
sym::rintf32 => "llvm.rint.f32",
68123
sym::rintf64 => "llvm.rint.f64",
124+
sym::rintf128 => "llvm.rint.f128",
125+
126+
sym::nearbyintf16 => "llvm.nearbyint.f16",
69127
sym::nearbyintf32 => "llvm.nearbyint.f32",
70128
sym::nearbyintf64 => "llvm.nearbyint.f64",
129+
sym::nearbyintf128 => "llvm.nearbyint.f128",
130+
131+
sym::roundf16 => "llvm.round.f16",
71132
sym::roundf32 => "llvm.round.f32",
72133
sym::roundf64 => "llvm.round.f64",
134+
sym::roundf128 => "llvm.round.f128",
135+
73136
sym::ptr_mask => "llvm.ptrmask",
137+
138+
sym::roundevenf16 => "llvm.roundeven.f16",
74139
sym::roundevenf32 => "llvm.roundeven.f32",
75140
sym::roundevenf64 => "llvm.roundeven.f64",
141+
sym::roundevenf128 => "llvm.roundeven.f128",
142+
76143
_ => return None,
77144
};
78145
Some(cx.get_intrinsic(llvm_name))

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

+3
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,9 @@ pub struct SanitizerOptions {
480480
pub sanitize_address: bool,
481481
pub sanitize_address_recover: bool,
482482
pub sanitize_cfi: bool,
483+
pub sanitize_dataflow: bool,
484+
pub sanitize_dataflow_abilist: *const *const c_char,
485+
pub sanitize_dataflow_abilist_len: size_t,
483486
pub sanitize_kcfi: bool,
484487
pub sanitize_memory: bool,
485488
pub sanitize_memory_recover: bool,

compiler/rustc_codegen_ssa/src/back/link.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,9 @@ fn add_sanitizer_libraries(
12211221
if sanitizer.contains(SanitizerSet::ADDRESS) {
12221222
link_sanitizer_runtime(sess, flavor, linker, "asan");
12231223
}
1224+
if sanitizer.contains(SanitizerSet::DATAFLOW) {
1225+
link_sanitizer_runtime(sess, flavor, linker, "dfsan");
1226+
}
12241227
if sanitizer.contains(SanitizerSet::LEAK) {
12251228
link_sanitizer_runtime(sess, flavor, linker, "lsan");
12261229
}

compiler/rustc_codegen_ssa/src/back/write.rs

+5
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ pub struct ModuleConfig {
9595

9696
pub sanitizer: SanitizerSet,
9797
pub sanitizer_recover: SanitizerSet,
98+
pub sanitizer_dataflow_abilist: Vec<String>,
9899
pub sanitizer_memory_track_origins: usize,
99100

100101
// Flags indicating which outputs to produce.
@@ -197,6 +198,10 @@ impl ModuleConfig {
197198
),
198199

199200
sanitizer: if_regular!(sess.opts.unstable_opts.sanitizer, SanitizerSet::empty()),
201+
sanitizer_dataflow_abilist: if_regular!(
202+
sess.opts.unstable_opts.sanitizer_dataflow_abilist.clone(),
203+
Vec::new()
204+
),
200205
sanitizer_recover: if_regular!(
201206
sess.opts.unstable_opts.sanitizer_recover,
202207
SanitizerSet::empty()

compiler/rustc_const_eval/src/util/compare_types.rs

+3-22
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//! other areas of the compiler as well.
55
66
use rustc_infer::infer::TyCtxtInferExt;
7-
use rustc_middle::traits::{DefiningAnchor, ObligationCause};
7+
use rustc_middle::traits::ObligationCause;
88
use rustc_middle::ty::{ParamEnv, Ty, TyCtxt, Variance};
99
use rustc_trait_selection::traits::ObligationCtxt;
1010

@@ -33,9 +33,6 @@ pub fn is_equal_up_to_subtyping<'tcx>(
3333
/// When validating assignments, the variance should be `Covariant`. When checking
3434
/// during `MirPhase` >= `MirPhase::Runtime(RuntimePhase::Initial)` variance should be `Invariant`
3535
/// because we want to check for type equality.
36-
///
37-
/// This mostly ignores opaque types as it can be used in constraining contexts
38-
/// while still computing the final underlying type.
3936
pub fn relate_types<'tcx>(
4037
tcx: TyCtxt<'tcx>,
4138
param_env: ParamEnv<'tcx>,
@@ -47,8 +44,7 @@ pub fn relate_types<'tcx>(
4744
return true;
4845
}
4946

50-
let mut builder =
51-
tcx.infer_ctxt().ignoring_regions().with_opaque_type_inference(DefiningAnchor::Bubble);
47+
let mut builder = tcx.infer_ctxt().ignoring_regions();
5248
let infcx = builder.build();
5349
let ocx = ObligationCtxt::new(&infcx);
5450
let cause = ObligationCause::dummy();
@@ -58,20 +54,5 @@ pub fn relate_types<'tcx>(
5854
Ok(()) => {}
5955
Err(_) => return false,
6056
};
61-
let errors = ocx.select_all_or_error();
62-
// With `Reveal::All`, opaque types get normalized away, with `Reveal::UserFacing`
63-
// we would get unification errors because we're unable to look into opaque types,
64-
// even if they're constrained in our current function.
65-
for (key, ty) in infcx.take_opaque_types() {
66-
let hidden_ty = tcx.type_of(key.def_id).instantiate(tcx, key.args);
67-
if hidden_ty != ty.hidden_type.ty {
68-
span_bug!(
69-
ty.hidden_type.span,
70-
"{}, {}",
71-
tcx.type_of(key.def_id).instantiate(tcx, key.args),
72-
ty.hidden_type.ty
73-
);
74-
}
75-
}
76-
errors.is_empty()
57+
ocx.select_all_or_error().is_empty()
7758
}

0 commit comments

Comments
 (0)