Skip to content

Commit a2df8ba

Browse files
committed
Auto merge of rust-lang#96224 - Dylan-DPC:rollup-h2h3j93, r=Dylan-DPC
Rollup of 6 pull requests Successful merges: - rust-lang#95740 (asm: Add a kreg0 register class on x86 which includes k0) - rust-lang#95813 (Remove extra space before a where clause) - rust-lang#96029 (Refactor loop into iterator; simplify negation logic.) - rust-lang#96162 (interpret: Fix writing uninit to an allocation) - rust-lang#96165 (Miri provenance cleanup) - rust-lang#96205 (Use futex locks on emscripten.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 4ca19e0 + da1ddf3 commit a2df8ba

File tree

23 files changed

+201
-115
lines changed

23 files changed

+201
-115
lines changed

compiler/rustc_codegen_gcc/src/asm.rs

+3
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,7 @@ fn reg_to_gcc(reg: InlineAsmRegOrRegClass) -> ConstraintOrRegister {
589589
| InlineAsmRegClass::X86(X86InlineAsmRegClass::ymm_reg) => "x",
590590
InlineAsmRegClass::X86(X86InlineAsmRegClass::zmm_reg) => "v",
591591
InlineAsmRegClass::X86(X86InlineAsmRegClass::kreg) => unimplemented!(),
592+
InlineAsmRegClass::X86(X86InlineAsmRegClass::kreg0) => unimplemented!(),
592593
InlineAsmRegClass::Wasm(WasmInlineAsmRegClass::local) => unimplemented!(),
593594
InlineAsmRegClass::X86(
594595
X86InlineAsmRegClass::x87_reg | X86InlineAsmRegClass::mmx_reg,
@@ -654,6 +655,7 @@ fn dummy_output_type<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, reg: InlineAsmRegCl
654655
| InlineAsmRegClass::X86(X86InlineAsmRegClass::zmm_reg) => cx.type_f32(),
655656
InlineAsmRegClass::X86(X86InlineAsmRegClass::x87_reg) => unimplemented!(),
656657
InlineAsmRegClass::X86(X86InlineAsmRegClass::kreg) => cx.type_i16(),
658+
InlineAsmRegClass::X86(X86InlineAsmRegClass::kreg0) => cx.type_i16(),
657659
InlineAsmRegClass::Wasm(WasmInlineAsmRegClass::local) => cx.type_i32(),
658660
InlineAsmRegClass::SpirV(SpirVInlineAsmRegClass::reg) => {
659661
bug!("LLVM backend does not support SPIR-V")
@@ -784,6 +786,7 @@ fn modifier_to_gcc(arch: InlineAsmArch, reg: InlineAsmRegClass, modifier: Option
784786
_ => unreachable!(),
785787
},
786788
InlineAsmRegClass::X86(X86InlineAsmRegClass::kreg) => None,
789+
InlineAsmRegClass::X86(X86InlineAsmRegClass::kreg0) => None,
787790
InlineAsmRegClass::X86(X86InlineAsmRegClass::x87_reg | X86InlineAsmRegClass::mmx_reg) => {
788791
unreachable!("clobber-only")
789792
}

compiler/rustc_codegen_llvm/src/asm.rs

+13-3
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,9 @@ fn reg_to_llvm(reg: InlineAsmRegOrRegClass, layout: Option<&TyAndLayout<'_>>) ->
602602
InlineAsmRegClass::X86(X86InlineAsmRegClass::zmm_reg) => "v",
603603
InlineAsmRegClass::X86(X86InlineAsmRegClass::kreg) => "^Yk",
604604
InlineAsmRegClass::X86(
605-
X86InlineAsmRegClass::x87_reg | X86InlineAsmRegClass::mmx_reg,
605+
X86InlineAsmRegClass::x87_reg
606+
| X86InlineAsmRegClass::mmx_reg
607+
| X86InlineAsmRegClass::kreg0,
606608
) => unreachable!("clobber-only"),
607609
InlineAsmRegClass::Wasm(WasmInlineAsmRegClass::local) => "r",
608610
InlineAsmRegClass::Bpf(BpfInlineAsmRegClass::reg) => "r",
@@ -687,7 +689,11 @@ fn modifier_to_llvm(
687689
_ => unreachable!(),
688690
},
689691
InlineAsmRegClass::X86(X86InlineAsmRegClass::kreg) => None,
690-
InlineAsmRegClass::X86(X86InlineAsmRegClass::x87_reg | X86InlineAsmRegClass::mmx_reg) => {
692+
InlineAsmRegClass::X86(
693+
X86InlineAsmRegClass::x87_reg
694+
| X86InlineAsmRegClass::mmx_reg
695+
| X86InlineAsmRegClass::kreg0,
696+
) => {
691697
unreachable!("clobber-only")
692698
}
693699
InlineAsmRegClass::Wasm(WasmInlineAsmRegClass::local) => None,
@@ -757,7 +763,11 @@ fn dummy_output_type<'ll>(cx: &CodegenCx<'ll, '_>, reg: InlineAsmRegClass) -> &'
757763
| InlineAsmRegClass::X86(X86InlineAsmRegClass::ymm_reg)
758764
| InlineAsmRegClass::X86(X86InlineAsmRegClass::zmm_reg) => cx.type_f32(),
759765
InlineAsmRegClass::X86(X86InlineAsmRegClass::kreg) => cx.type_i16(),
760-
InlineAsmRegClass::X86(X86InlineAsmRegClass::x87_reg | X86InlineAsmRegClass::mmx_reg) => {
766+
InlineAsmRegClass::X86(
767+
X86InlineAsmRegClass::x87_reg
768+
| X86InlineAsmRegClass::mmx_reg
769+
| X86InlineAsmRegClass::kreg0,
770+
) => {
761771
unreachable!("clobber-only")
762772
}
763773
InlineAsmRegClass::Wasm(WasmInlineAsmRegClass::local) => cx.type_i32(),

compiler/rustc_const_eval/src/const_eval/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub(crate) fn const_caller_location(
3838
if intern_const_alloc_recursive(&mut ecx, InternKind::Constant, &loc_place).is_err() {
3939
bug!("intern_const_alloc_recursive should not error in this case")
4040
}
41-
ConstValue::Scalar(Scalar::from_pointer(loc_place.ptr.into_pointer_or_addr().unwrap(), &tcx))
41+
ConstValue::Scalar(Scalar::from_maybe_pointer(loc_place.ptr, &tcx))
4242
}
4343

4444
/// Convert an evaluated constant to a type level constant

compiler/rustc_const_eval/src/interpret/machine.rs

+21-7
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ pub trait Machine<'mir, 'tcx>: Sized {
8888
/// Pointers are "tagged" with provenance information; typically the `AllocId` they belong to.
8989
type PointerTag: Provenance + Eq + Hash + 'static;
9090

91+
/// When getting the AllocId of a pointer, some extra data is also obtained from the tag
92+
/// that is passed to memory access hooks so they can do things with it.
93+
type TagExtra: Copy + 'static;
94+
9195
/// Machines can define extra (non-instance) things that represent values of function pointers.
9296
/// For example, Miri uses this to return a function pointer from `dlsym`
9397
/// that can later be called to execute the right thing.
@@ -122,6 +126,8 @@ pub trait Machine<'mir, 'tcx>: Sized {
122126

123127
/// Whether, when checking alignment, we should `force_int` and thus support
124128
/// custom alignment logic based on whatever the integer address happens to be.
129+
///
130+
/// Requires PointerTag::OFFSET_IS_ADDR to be true.
125131
fn force_int_for_alignment_check(ecx: &InterpCx<'mir, 'tcx, Self>) -> bool;
126132

127133
/// Whether to enforce the validity invariant
@@ -285,11 +291,14 @@ pub trait Machine<'mir, 'tcx>: Sized {
285291
addr: u64,
286292
) -> Pointer<Option<Self::PointerTag>>;
287293

288-
/// Convert a pointer with provenance into an allocation-offset pair.
294+
/// Convert a pointer with provenance into an allocation-offset pair
295+
/// and extra provenance info.
296+
///
297+
/// The returned `AllocId` must be the same as `ptr.provenance.get_alloc_id()`.
289298
fn ptr_get_alloc(
290299
ecx: &InterpCx<'mir, 'tcx, Self>,
291300
ptr: Pointer<Self::PointerTag>,
292-
) -> (AllocId, Size);
301+
) -> (AllocId, Size, Self::TagExtra);
293302

294303
/// Called to initialize the "extra" state of an allocation and make the pointers
295304
/// it contains (in relocations) tagged. The way we construct allocations is
@@ -321,7 +330,7 @@ pub trait Machine<'mir, 'tcx>: Sized {
321330
_tcx: TyCtxt<'tcx>,
322331
_machine: &Self,
323332
_alloc_extra: &Self::AllocExtra,
324-
_tag: Self::PointerTag,
333+
_tag: (AllocId, Self::TagExtra),
325334
_range: AllocRange,
326335
) -> InterpResult<'tcx> {
327336
Ok(())
@@ -333,7 +342,7 @@ pub trait Machine<'mir, 'tcx>: Sized {
333342
_tcx: TyCtxt<'tcx>,
334343
_machine: &mut Self,
335344
_alloc_extra: &mut Self::AllocExtra,
336-
_tag: Self::PointerTag,
345+
_tag: (AllocId, Self::TagExtra),
337346
_range: AllocRange,
338347
) -> InterpResult<'tcx> {
339348
Ok(())
@@ -345,7 +354,7 @@ pub trait Machine<'mir, 'tcx>: Sized {
345354
_tcx: TyCtxt<'tcx>,
346355
_machine: &mut Self,
347356
_alloc_extra: &mut Self::AllocExtra,
348-
_tag: Self::PointerTag,
357+
_tag: (AllocId, Self::TagExtra),
349358
_range: AllocRange,
350359
) -> InterpResult<'tcx> {
351360
Ok(())
@@ -397,6 +406,8 @@ pub trait Machine<'mir, 'tcx>: Sized {
397406
// (CTFE and ConstProp) use the same instance. Here, we share that code.
398407
pub macro compile_time_machine(<$mir: lifetime, $tcx: lifetime>) {
399408
type PointerTag = AllocId;
409+
type TagExtra = ();
410+
400411
type ExtraFnVal = !;
401412

402413
type MemoryMap =
@@ -474,9 +485,12 @@ pub macro compile_time_machine(<$mir: lifetime, $tcx: lifetime>) {
474485
}
475486

476487
#[inline(always)]
477-
fn ptr_get_alloc(_ecx: &InterpCx<$mir, $tcx, Self>, ptr: Pointer<AllocId>) -> (AllocId, Size) {
488+
fn ptr_get_alloc(
489+
_ecx: &InterpCx<$mir, $tcx, Self>,
490+
ptr: Pointer<AllocId>,
491+
) -> (AllocId, Size, Self::TagExtra) {
478492
// We know `offset` is relative to the allocation, so we can use `into_parts`.
479493
let (alloc_id, offset) = ptr.into_parts();
480-
(alloc_id, offset)
494+
(alloc_id, offset, ())
481495
}
482496
}

0 commit comments

Comments
 (0)