@@ -35,15 +35,29 @@ pub fn inline(sess: &Session, module: &mut Module) -> super::Result<()> {
3535 // Drop all the functions we'll be inlining. (This also means we won't waste time processing
3636 // inlines in functions that will get inlined)
3737 let mut dropped_ids = FxHashSet :: default ( ) ;
38+ let mut inlined_dont_inlines = Vec :: new ( ) ;
3839 module. functions . retain ( |f| {
3940 if should_inline ( & disallowed_argument_types, & disallowed_return_types, f) {
41+ if has_dont_inline ( f) {
42+ inlined_dont_inlines. push ( f. def_id ( ) . unwrap ( ) ) ;
43+ }
4044 // TODO: We should insert all defined IDs in this function.
4145 dropped_ids. insert ( f. def_id ( ) . unwrap ( ) ) ;
4246 false
4347 } else {
4448 true
4549 }
4650 } ) ;
51+ if !inlined_dont_inlines. is_empty ( ) {
52+ let names = get_names ( module) ;
53+ for f in inlined_dont_inlines {
54+ sess. warn ( & format ! (
55+ "function `{}` has `dont_inline` attribute, but need to be inlined because it has illegal argument or return types" ,
56+ get_name( & names, f)
57+ ) ) ;
58+ }
59+ }
60+
4761 // Drop OpName etc. for inlined functions
4862 module. debug_names . retain ( |inst| {
4963 !inst. operands . iter ( ) . any ( |op| {
@@ -204,6 +218,12 @@ fn compute_disallowed_argument_and_return_types(
204218 ( disallowed_argument_types, disallowed_return_types)
205219}
206220
221+ fn has_dont_inline ( function : & Function ) -> bool {
222+ let def = function. def . as_ref ( ) . unwrap ( ) ;
223+ let control = def. operands [ 0 ] . unwrap_function_control ( ) ;
224+ control. contains ( FunctionControl :: DONT_INLINE )
225+ }
226+
207227fn should_inline (
208228 disallowed_argument_types : & FxHashSet < Word > ,
209229 disallowed_return_types : & FxHashSet < Word > ,
0 commit comments