1
1
use crate :: dep_graph:: { DepNode , WorkProduct , WorkProductId } ;
2
2
use crate :: ty:: { GenericArgs , Instance , InstanceDef , SymbolName , TyCtxt } ;
3
- use rustc_attr:: InlineAttr ;
4
3
use rustc_data_structures:: base_n;
5
4
use rustc_data_structures:: fingerprint:: Fingerprint ;
6
5
use rustc_data_structures:: fx:: FxHashMap ;
@@ -9,7 +8,6 @@ use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
9
8
use rustc_hir:: ItemId ;
10
9
use rustc_index:: Idx ;
11
10
use rustc_query_system:: ich:: StableHashingContext ;
12
- use rustc_session:: config:: OptLevel ;
13
11
use rustc_span:: source_map:: Span ;
14
12
use rustc_span:: symbol:: Symbol ;
15
13
use std:: fmt;
@@ -96,13 +94,9 @@ impl<'tcx> MonoItem<'tcx> {
96
94
}
97
95
98
96
pub fn instantiation_mode ( & self , tcx : TyCtxt < ' tcx > ) -> InstantiationMode {
99
- let generate_cgu_internal_copies = tcx
100
- . sess
101
- . opts
102
- . unstable_opts
103
- . inline_in_all_cgus
104
- . unwrap_or_else ( || tcx. sess . opts . optimize != OptLevel :: No )
105
- && !tcx. sess . link_dead_code ( ) ;
97
+ let generate_cgu_internal_copies =
98
+ tcx. sess . opts . unstable_opts . inline_in_all_cgus . unwrap_or ( false )
99
+ && !tcx. sess . link_dead_code ( ) ;
106
100
107
101
match * self {
108
102
MonoItem :: Fn ( ref instance) => {
@@ -123,15 +117,7 @@ impl<'tcx> MonoItem<'tcx> {
123
117
return InstantiationMode :: LocalCopy ;
124
118
}
125
119
126
- // Finally, if this is `#[inline(always)]` we're sure to respect
127
- // that with an inline copy per CGU, but otherwise we'll be
128
- // creating one copy of this `#[inline]` function which may
129
- // conflict with upstream crates as it could be an exported
130
- // symbol.
131
- match tcx. codegen_fn_attrs ( instance. def_id ( ) ) . inline {
132
- InlineAttr :: Always => InstantiationMode :: LocalCopy ,
133
- _ => InstantiationMode :: GloballyShared { may_conflict : true } ,
134
- }
120
+ return InstantiationMode :: GloballyShared { may_conflict : true } ;
135
121
}
136
122
MonoItem :: Static ( ..) | MonoItem :: GlobalAsm ( ..) => {
137
123
InstantiationMode :: GloballyShared { may_conflict : false }
0 commit comments