mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-16 17:03:35 +00:00
Rollup merge of #96650 - tmiasko:global-asm-sym-fn, r=Amanieu
Collect function instance used in `global_asm!` sym operand The constants used in SymFn operands have FnDef type, so the type of the constant identifies the function. Fixes #96623.
This commit is contained in:
commit
c7af4e67c3
@ -445,12 +445,9 @@ fn collect_items_rec<'tcx>(
|
|||||||
// depend on any other items.
|
// depend on any other items.
|
||||||
}
|
}
|
||||||
hir::InlineAsmOperand::SymFn { anon_const } => {
|
hir::InlineAsmOperand::SymFn { anon_const } => {
|
||||||
let def_id = tcx.hir().body_owner_def_id(anon_const.body).to_def_id();
|
let fn_ty =
|
||||||
if let Ok(val) = tcx.const_eval_poly(def_id) {
|
tcx.typeck_body(anon_const.body).node_type(anon_const.hir_id);
|
||||||
rustc_data_structures::stack::ensure_sufficient_stack(|| {
|
visit_fn_use(tcx, fn_ty, false, *op_sp, &mut neighbors);
|
||||||
collect_const_value(tcx, val, &mut neighbors);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
hir::InlineAsmOperand::SymStatic { path: _, def_id } => {
|
hir::InlineAsmOperand::SymStatic { path: _, def_id } => {
|
||||||
let instance = Instance::mono(tcx, *def_id);
|
let instance = Instance::mono(tcx, *def_id);
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// only-linux
|
// only-linux
|
||||||
// assembly-output: emit-asm
|
// assembly-output: emit-asm
|
||||||
// compile-flags: -C llvm-args=--x86-asm-syntax=intel
|
// compile-flags: -C llvm-args=--x86-asm-syntax=intel
|
||||||
|
// compile-flags: -C symbol-mangling-version=v0
|
||||||
|
|
||||||
#![feature(asm_const, asm_sym)]
|
#![feature(asm_const, asm_sym)]
|
||||||
#![crate_type = "rlib"]
|
#![crate_type = "rlib"]
|
||||||
@ -24,3 +25,7 @@ global_asm!("movl ${}, %ecx", const 5, options(att_syntax));
|
|||||||
global_asm!("call {}", sym my_func);
|
global_asm!("call {}", sym my_func);
|
||||||
// CHECK: lea rax, [rip + MY_STATIC]
|
// CHECK: lea rax, [rip + MY_STATIC]
|
||||||
global_asm!("lea rax, [rip + {}]", sym MY_STATIC);
|
global_asm!("lea rax, [rip + {}]", sym MY_STATIC);
|
||||||
|
// CHECK: call _RNvCsiubXh4Yz005_10global_asm6foobar
|
||||||
|
global_asm!("call {}", sym foobar);
|
||||||
|
// CHECK: _RNvCsiubXh4Yz005_10global_asm6foobar:
|
||||||
|
fn foobar() { loop {} }
|
||||||
|
Loading…
Reference in New Issue
Block a user