Skip to content

Commit 9ab8588

Browse files
committed
Sync from rust 4cb17b4
2 parents 0dc13d7 + d390c00 commit 9ab8588

File tree

11 files changed

+89
-88
lines changed

11 files changed

+89
-88
lines changed

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ gimli = { version = "0.28", default-features = false, features = ["write"]}
1919
object = { version = "0.32", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] }
2020

2121
indexmap = "2.0.0"
22-
libloading = { version = "0.7.3", optional = true }
22+
libloading = { version = "0.8.0", optional = true }
2323
smallvec = "1.8.1"
2424

2525
[patch.crates-io]

example/mini_core_hello_world.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ fn start<T: Termination + 'static>(
111111
}
112112

113113
static mut NUM: u8 = 6 * 7;
114+
115+
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_ref` lint
116+
#[allow(static_mut_ref)]
114117
static NUM_REF: &'static u8 = unsafe { &NUM };
115118

116119
unsafe fn zeroed<T>() -> T {

src/abi/mod.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use cranelift_module::ModuleError;
1111
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
1212
use rustc_middle::ty::layout::FnAbiOf;
1313
use rustc_session::Session;
14+
use rustc_span::source_map::Spanned;
1415
use rustc_target::abi::call::{Conv, FnAbi};
1516
use rustc_target::spec::abi::Abi;
1617

@@ -360,7 +361,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
360361
fx: &mut FunctionCx<'_, '_, 'tcx>,
361362
source_info: mir::SourceInfo,
362363
func: &Operand<'tcx>,
363-
args: &[Operand<'tcx>],
364+
args: &[Spanned<Operand<'tcx>>],
364365
destination: Place<'tcx>,
365366
target: Option<BasicBlock>,
366367
) {
@@ -415,7 +416,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
415416

416417
let extra_args = &args[fn_sig.inputs().skip_binder().len()..];
417418
let extra_args = fx.tcx.mk_type_list_from_iter(
418-
extra_args.iter().map(|op_arg| fx.monomorphize(op_arg.ty(fx.mir, fx.tcx))),
419+
extra_args.iter().map(|op_arg| fx.monomorphize(op_arg.node.ty(fx.mir, fx.tcx))),
419420
);
420421
let fn_abi = if let Some(instance) = instance {
421422
RevealAllLayoutCx(fx.tcx).fn_abi_of_instance(instance, extra_args)
@@ -440,10 +441,10 @@ pub(crate) fn codegen_terminator_call<'tcx>(
440441
// Unpack arguments tuple for closures
441442
let mut args = if fn_sig.abi() == Abi::RustCall {
442443
let (self_arg, pack_arg) = match args {
443-
[pack_arg] => (None, codegen_call_argument_operand(fx, pack_arg)),
444+
[pack_arg] => (None, codegen_call_argument_operand(fx, &pack_arg.node)),
444445
[self_arg, pack_arg] => (
445-
Some(codegen_call_argument_operand(fx, self_arg)),
446-
codegen_call_argument_operand(fx, pack_arg),
446+
Some(codegen_call_argument_operand(fx, &self_arg.node)),
447+
codegen_call_argument_operand(fx, &pack_arg.node),
447448
),
448449
_ => panic!("rust-call abi requires one or two arguments"),
449450
};
@@ -463,7 +464,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
463464
}
464465
args
465466
} else {
466-
args.iter().map(|arg| codegen_call_argument_operand(fx, arg)).collect::<Vec<_>>()
467+
args.iter().map(|arg| codegen_call_argument_operand(fx, &arg.node)).collect::<Vec<_>>()
467468
};
468469

469470
// Pass the caller location for `#[track_caller]`.

src/debuginfo/line_info.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,7 @@ impl DebugContext {
6868
// In order to have a good line stepping behavior in debugger, we overwrite debug
6969
// locations of macro expansions with that of the outermost expansion site (when the macro is
7070
// annotated with `#[collapse_debuginfo]` or when `-Zdebug-macros` is provided).
71-
let span = if tcx.should_collapse_debuginfo(span) {
72-
span
73-
} else {
74-
// Walk up the macro expansion chain until we reach a non-expanded span.
75-
// We also stop at the function body level because no line stepping can occur
76-
// at the level above that.
77-
rustc_span::hygiene::walk_chain(span, function_span.ctxt())
78-
};
79-
71+
let span = tcx.collapsed_debuginfo(span, function_span);
8072
match tcx.sess.source_map().lookup_line(span.lo()) {
8173
Ok(SourceFileAndLine { sf: file, line }) => {
8274
let line_pos = file.lines()[line];

src/driver/jit.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,10 @@ fn dep_symbol_lookup_fn(
321321
Linkage::NotLinked | Linkage::IncludedFromDylib => {}
322322
Linkage::Static => {
323323
let name = crate_info.crate_name[&cnum];
324-
let mut err = sess.dcx().struct_err(format!("Can't load static lib {}", name));
325-
err.note("rustc_codegen_cranelift can only load dylibs in JIT mode.");
326-
err.emit();
324+
sess.dcx()
325+
.struct_err(format!("Can't load static lib {}", name))
326+
.note("rustc_codegen_cranelift can only load dylibs in JIT mode.")
327+
.emit();
327328
}
328329
Linkage::Dynamic => {
329330
dylib_paths.push(src.dylib.as_ref().unwrap().0.clone());

src/intrinsics/llvm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub(crate) fn codegen_llvm_intrinsic_call<'tcx>(
77
fx: &mut FunctionCx<'_, '_, 'tcx>,
88
intrinsic: &str,
99
generic_args: GenericArgsRef<'tcx>,
10-
args: &[mir::Operand<'tcx>],
10+
args: &[Spanned<mir::Operand<'tcx>>],
1111
ret: CPlace<'tcx>,
1212
target: Option<BasicBlock>,
1313
span: Span,

src/intrinsics/llvm_aarch64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub(crate) fn codegen_aarch64_llvm_intrinsic_call<'tcx>(
77
fx: &mut FunctionCx<'_, '_, 'tcx>,
88
intrinsic: &str,
99
_args: GenericArgsRef<'tcx>,
10-
args: &[mir::Operand<'tcx>],
10+
args: &[Spanned<mir::Operand<'tcx>>],
1111
ret: CPlace<'tcx>,
1212
target: Option<BasicBlock>,
1313
) {

src/intrinsics/llvm_x86.rs

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>(
1111
fx: &mut FunctionCx<'_, '_, 'tcx>,
1212
intrinsic: &str,
1313
_args: GenericArgsRef<'tcx>,
14-
args: &[mir::Operand<'tcx>],
14+
args: &[Spanned<mir::Operand<'tcx>>],
1515
ret: CPlace<'tcx>,
1616
target: Option<BasicBlock>,
1717
span: Span,
@@ -175,9 +175,9 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>(
175175
[x, y, kind] => (x, y, kind),
176176
_ => bug!("wrong number of args for intrinsic {intrinsic}"),
177177
};
178-
let x = codegen_operand(fx, x);
179-
let y = codegen_operand(fx, y);
180-
let kind = match kind {
178+
let x = codegen_operand(fx, &x.node);
179+
let y = codegen_operand(fx, &y.node);
180+
let kind = match &kind.node {
181181
Operand::Constant(const_) => crate::constant::eval_mir_constant(fx, const_).0,
182182
Operand::Copy(_) | Operand::Move(_) => unreachable!("{kind:?}"),
183183
};
@@ -287,8 +287,8 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>(
287287
[a, b] => (a, b),
288288
_ => bug!("wrong number of args for intrinsic {intrinsic}"),
289289
};
290-
let a = codegen_operand(fx, a);
291-
let b = codegen_operand(fx, b);
290+
let a = codegen_operand(fx, &a.node);
291+
let b = codegen_operand(fx, &b.node);
292292

293293
// Based on the pseudocode at https://github.com/rust-lang/stdarch/blob/1cfbca8b38fd9b4282b2f054f61c6ca69fc7ce29/crates/core_arch/src/x86/avx2.rs#L2319-L2332
294294
let zero = fx.bcx.ins().iconst(types::I8, 0);
@@ -325,9 +325,9 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>(
325325
[a, b, imm8] => (a, b, imm8),
326326
_ => bug!("wrong number of args for intrinsic {intrinsic}"),
327327
};
328-
let a = codegen_operand(fx, a);
329-
let b = codegen_operand(fx, b);
330-
let imm8 = codegen_operand(fx, imm8).load_scalar(fx);
328+
let a = codegen_operand(fx, &a.node);
329+
let b = codegen_operand(fx, &b.node);
330+
let imm8 = codegen_operand(fx, &imm8.node).load_scalar(fx);
331331

332332
let a_low = a.value_typed_lane(fx, fx.tcx.types.u128, 0).load_scalar(fx);
333333
let a_high = a.value_typed_lane(fx, fx.tcx.types.u128, 1).load_scalar(fx);
@@ -782,14 +782,14 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>(
782782
let b = b.load_scalar(fx);
783783
let lb = lb.load_scalar(fx);
784784

785-
let imm8 = if let Some(imm8) = crate::constant::mir_operand_get_const_val(fx, &args[4])
786-
{
787-
imm8
788-
} else {
789-
fx.tcx
790-
.dcx()
791-
.span_fatal(span, "Index argument for `_mm_cmpestri` is not a constant");
792-
};
785+
let imm8 =
786+
if let Some(imm8) = crate::constant::mir_operand_get_const_val(fx, &args[4].node) {
787+
imm8
788+
} else {
789+
fx.tcx
790+
.dcx()
791+
.span_fatal(span, "Index argument for `_mm_cmpestri` is not a constant");
792+
};
793793

794794
let imm8 = imm8.try_to_u8().unwrap_or_else(|_| panic!("kind not scalar: {:?}", imm8));
795795

@@ -835,14 +835,14 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>(
835835
let b = b.load_scalar(fx);
836836
let lb = lb.load_scalar(fx);
837837

838-
let imm8 = if let Some(imm8) = crate::constant::mir_operand_get_const_val(fx, &args[4])
839-
{
840-
imm8
841-
} else {
842-
fx.tcx
843-
.dcx()
844-
.span_fatal(span, "Index argument for `_mm_cmpestrm` is not a constant");
845-
};
838+
let imm8 =
839+
if let Some(imm8) = crate::constant::mir_operand_get_const_val(fx, &args[4].node) {
840+
imm8
841+
} else {
842+
fx.tcx
843+
.dcx()
844+
.span_fatal(span, "Index argument for `_mm_cmpestrm` is not a constant");
845+
};
846846

847847
let imm8 = imm8.try_to_u8().unwrap_or_else(|_| panic!("kind not scalar: {:?}", imm8));
848848

@@ -882,15 +882,15 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>(
882882
let a = a.load_scalar(fx);
883883
let b = b.load_scalar(fx);
884884

885-
let imm8 = if let Some(imm8) = crate::constant::mir_operand_get_const_val(fx, &args[2])
886-
{
887-
imm8
888-
} else {
889-
fx.tcx.dcx().span_fatal(
890-
span,
891-
"Index argument for `_mm_clmulepi64_si128` is not a constant",
892-
);
893-
};
885+
let imm8 =
886+
if let Some(imm8) = crate::constant::mir_operand_get_const_val(fx, &args[2].node) {
887+
imm8
888+
} else {
889+
fx.tcx.dcx().span_fatal(
890+
span,
891+
"Index argument for `_mm_clmulepi64_si128` is not a constant",
892+
);
893+
};
894894

895895
let imm8 = imm8.try_to_u8().unwrap_or_else(|_| panic!("kind not scalar: {:?}", imm8));
896896

@@ -919,15 +919,15 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>(
919919

920920
let a = a.load_scalar(fx);
921921

922-
let imm8 = if let Some(imm8) = crate::constant::mir_operand_get_const_val(fx, &args[1])
923-
{
924-
imm8
925-
} else {
926-
fx.tcx.dcx().span_fatal(
927-
span,
928-
"Index argument for `_mm_aeskeygenassist_si128` is not a constant",
929-
);
930-
};
922+
let imm8 =
923+
if let Some(imm8) = crate::constant::mir_operand_get_const_val(fx, &args[1].node) {
924+
imm8
925+
} else {
926+
fx.tcx.dcx().span_fatal(
927+
span,
928+
"Index argument for `_mm_aeskeygenassist_si128` is not a constant",
929+
);
930+
};
931931

932932
let imm8 = imm8.try_to_u8().unwrap_or_else(|_| panic!("kind not scalar: {:?}", imm8));
933933

src/intrinsics/mod.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ macro_rules! intrinsic_args {
55
($fx:expr, $args:expr => ($($arg:tt),*); $intrinsic:expr) => {
66
#[allow(unused_parens)]
77
let ($($arg),*) = if let [$($arg),*] = $args {
8-
($(codegen_operand($fx, $arg)),*)
8+
($(codegen_operand($fx, &($arg).node)),*)
99
} else {
1010
$crate::intrinsics::bug_on_incorrect_arg_count($intrinsic);
1111
};
@@ -22,6 +22,7 @@ use rustc_middle::ty;
2222
use rustc_middle::ty::layout::{HasParamEnv, ValidityRequirement};
2323
use rustc_middle::ty::print::{with_no_trimmed_paths, with_no_visible_paths};
2424
use rustc_middle::ty::GenericArgsRef;
25+
use rustc_span::source_map::Spanned;
2526
use rustc_span::symbol::{kw, sym, Symbol};
2627

2728
pub(crate) use self::llvm::codegen_llvm_intrinsic_call;
@@ -263,7 +264,7 @@ fn bool_to_zero_or_max_uint<'tcx>(
263264
pub(crate) fn codegen_intrinsic_call<'tcx>(
264265
fx: &mut FunctionCx<'_, '_, 'tcx>,
265266
instance: Instance<'tcx>,
266-
args: &[mir::Operand<'tcx>],
267+
args: &[Spanned<mir::Operand<'tcx>>],
267268
destination: CPlace<'tcx>,
268269
target: Option<BasicBlock>,
269270
source_info: mir::SourceInfo,
@@ -301,7 +302,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>(
301302
fn codegen_float_intrinsic_call<'tcx>(
302303
fx: &mut FunctionCx<'_, '_, 'tcx>,
303304
intrinsic: Symbol,
304-
args: &[mir::Operand<'tcx>],
305+
args: &[Spanned<mir::Operand<'tcx>>],
305306
ret: CPlace<'tcx>,
306307
) -> bool {
307308
let (name, arg_count, ty, clif_ty) = match intrinsic {
@@ -353,18 +354,21 @@ fn codegen_float_intrinsic_call<'tcx>(
353354
let (a, b, c);
354355
let args = match args {
355356
[x] => {
356-
a = [codegen_operand(fx, x).load_scalar(fx)];
357+
a = [codegen_operand(fx, &x.node).load_scalar(fx)];
357358
&a as &[_]
358359
}
359360
[x, y] => {
360-
b = [codegen_operand(fx, x).load_scalar(fx), codegen_operand(fx, y).load_scalar(fx)];
361+
b = [
362+
codegen_operand(fx, &x.node).load_scalar(fx),
363+
codegen_operand(fx, &y.node).load_scalar(fx),
364+
];
361365
&b
362366
}
363367
[x, y, z] => {
364368
c = [
365-
codegen_operand(fx, x).load_scalar(fx),
366-
codegen_operand(fx, y).load_scalar(fx),
367-
codegen_operand(fx, z).load_scalar(fx),
369+
codegen_operand(fx, &x.node).load_scalar(fx),
370+
codegen_operand(fx, &y.node).load_scalar(fx),
371+
codegen_operand(fx, &z.node).load_scalar(fx),
368372
];
369373
&c
370374
}
@@ -422,7 +426,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
422426
instance: Instance<'tcx>,
423427
intrinsic: Symbol,
424428
generic_args: GenericArgsRef<'tcx>,
425-
args: &[mir::Operand<'tcx>],
429+
args: &[Spanned<mir::Operand<'tcx>>],
426430
ret: CPlace<'tcx>,
427431
destination: Option<BasicBlock>,
428432
source_info: mir::SourceInfo,

0 commit comments

Comments
 (0)