Exclude global_asm from mir_keys
This commit is contained in:
parent
c867b8f11d
commit
ef031c854d
3 changed files with 31 additions and 1 deletions
|
@ -316,6 +316,10 @@ fn mir_keys(tcx: TyCtxt<'_>, (): ()) -> FxIndexSet<LocalDefId> {
|
||||||
// All body-owners have MIR associated with them.
|
// All body-owners have MIR associated with them.
|
||||||
let mut set: FxIndexSet<_> = tcx.hir_body_owners().collect();
|
let mut set: FxIndexSet<_> = tcx.hir_body_owners().collect();
|
||||||
|
|
||||||
|
// Remove the fake bodies for `global_asm!`, since they're not useful
|
||||||
|
// to be emitted (`--emit=mir`) or encoded (in metadata).
|
||||||
|
set.retain(|&def_id| !matches!(tcx.def_kind(def_id), DefKind::GlobalAsm));
|
||||||
|
|
||||||
// Coroutine-closures (e.g. async closures) have an additional by-move MIR
|
// Coroutine-closures (e.g. async closures) have an additional by-move MIR
|
||||||
// body that isn't in the HIR.
|
// body that isn't in the HIR.
|
||||||
for body_owner in tcx.hir_body_owners() {
|
for body_owner in tcx.hir_body_owners() {
|
||||||
|
|
26
tests/ui/asm/global-asm-isnt-really-a-mir-body.rs
Normal file
26
tests/ui/asm/global-asm-isnt-really-a-mir-body.rs
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
//@ revisions: emit_mir instrument cfi
|
||||||
|
|
||||||
|
// Make sure we don't try to emit MIR for it.
|
||||||
|
//@[emit_mir] compile-flags: --emit=mir
|
||||||
|
|
||||||
|
// Make sure we don't try to instrument it.
|
||||||
|
//@[instrument] compile-flags: -Cinstrument-coverage -Zno-profiler-runtime
|
||||||
|
//@[instrument] only-linux
|
||||||
|
|
||||||
|
// Make sure we don't try to CFI encode it.
|
||||||
|
//@[cfi] compile-flags: -Zsanitizer=cfi -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Clink-dead-code=true
|
||||||
|
//@[cfi] needs-sanitizer-cfi
|
||||||
|
//@[cfi] no-prefer-dynamic
|
||||||
|
// FIXME(#122848) Remove only-linux once OSX CFI binaries work
|
||||||
|
//@[cfi] only-linux
|
||||||
|
|
||||||
|
//@ build-pass
|
||||||
|
//@ needs-asm-support
|
||||||
|
|
||||||
|
use std::arch::global_asm;
|
||||||
|
|
||||||
|
fn foo() {}
|
||||||
|
|
||||||
|
global_asm!("/* {} */", sym foo);
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -1,5 +1,5 @@
|
||||||
error[E0425]: cannot find value `a` in this scope
|
error[E0425]: cannot find value `a` in this scope
|
||||||
--> $DIR/global-asm-with-error.rs:6:29
|
--> $DIR/global-asm-with-error.rs:8:29
|
||||||
|
|
|
|
||||||
LL | global_asm!("/* {} */", sym a);
|
LL | global_asm!("/* {} */", sym a);
|
||||||
| ^ not found in this scope
|
| ^ not found in this scope
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue