Exclude global_asm from mir_keys · rust-lang/rust@dc9d559 (original) (raw)

File tree

2 files changed

lines changed

2 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -316,6 +316,10 @@ fn mir_keys(tcx: TyCtxt<'_>, (): ()) -> FxIndexSet {
316 316 // All body-owners have MIR associated with them.
317 317 let mut set: FxIndexSet<_> = tcx.hir_body_owners().collect();
318 318
319 +// Remove the fake bodies for `global_asm!`, since they're not useful
320 +// to be emitted (`--emit=mir`) or encoded (in metadata).
321 + set.retain(|&def_id
322 +
319 323 // Coroutine-closures (e.g. async closures) have an additional by-move MIR
320 324 // body that isn't in the HIR.
321 325 for body_owner in tcx.hir_body_owners() {
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
1 +//@ revisions: emit_mir instrument cfi
2 +
3 +// Make sure we don't try to emit MIR for it.
4 +//@[emit_mir] compile-flags: --emit=mir
5 +
6 +// Make sure we don't try to instrument it.
7 +//@[instrument] compile-flags: -Cinstrument-coverage -Zno-profiler-runtime
8 +//@[instrument] only-linux
9 +
10 +// Make sure we don't try to CFI encode it.
11 +//@[cfi] compile-flags: -Zsanitizer=cfi -Ccodegen-units=1 -Clto -Clink-dead-code=true
12 +//@[cfi] needs-sanitizer-cfi
13 +//@[cfi] no-prefer-dynamic
14 +
15 +//@ build-pass
16 +
17 +use std::arch::global_asm;
18 +
19 +fn foo() {}
20 +
21 +global_asm!("/* {} */", sym foo);
22 +
23 +fn main() {}