File tree 2 files changed +31
-0
lines changed
compiler/rustc_passes/src
src/test/codegen-units/item-collection
2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,17 @@ impl<'tcx> Visitor<'tcx> for ReachableContext<'tcx> {
116
116
117
117
intravisit:: walk_expr ( self , expr)
118
118
}
119
+
120
+ fn visit_inline_asm ( & mut self , asm : & ' tcx hir:: InlineAsm < ' tcx > , id : hir:: HirId ) {
121
+ for ( op, _) in asm. operands {
122
+ if let hir:: InlineAsmOperand :: SymStatic { def_id, .. } = op {
123
+ if let Some ( def_id) = def_id. as_local ( ) {
124
+ self . reachable_symbols . insert ( def_id) ;
125
+ }
126
+ }
127
+ }
128
+ intravisit:: walk_inline_asm ( self , asm, id) ;
129
+ }
119
130
}
120
131
121
132
impl < ' tcx > ReachableContext < ' tcx > {
Original file line number Diff line number Diff line change
1
+ // needs-asm-support
2
+ // compile-flags: -Ccodegen-units=1 -Zprint-mono-items=lazy --crate-type=lib
3
+
4
+ #[ inline( always) ]
5
+ pub unsafe fn f ( ) {
6
+ //~ MONO_ITEM static f::S @@ asm_sym-cgu.0[External]
7
+ static S : usize = 1 ;
8
+ //~ MONO_ITEM fn f::fun @@ asm_sym-cgu.0[External]
9
+ fn fun ( ) { }
10
+ core:: arch:: asm!( "/* {0} {1} */" , sym S , sym fun) ;
11
+ }
12
+
13
+ //~ MONO_ITEM fn g @@ asm_sym-cgu.0[External]
14
+ pub unsafe fn g ( ) {
15
+ //~ MONO_ITEM static g::S @@ asm_sym-cgu.0[Internal]
16
+ static S : usize = 2 ;
17
+ //~ MONO_ITEM fn g::fun @@ asm_sym-cgu.0[Internal]
18
+ fn fun ( ) { }
19
+ core:: arch:: asm!( "/* {0} {1} */" , sym S , sym fun) ;
20
+ }
You can’t perform that action at this time.
0 commit comments