@@ -35,15 +35,29 @@ pub fn inline(sess: &Session, module: &mut Module) -> super::Result<()> {
35
35
// Drop all the functions we'll be inlining. (This also means we won't waste time processing
36
36
// inlines in functions that will get inlined)
37
37
let mut dropped_ids = FxHashSet :: default ( ) ;
38
+ let mut inlined_dont_inlines = Vec :: new ( ) ;
38
39
module. functions . retain ( |f| {
39
40
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
+ }
40
44
// TODO: We should insert all defined IDs in this function.
41
45
dropped_ids. insert ( f. def_id ( ) . unwrap ( ) ) ;
42
46
false
43
47
} else {
44
48
true
45
49
}
46
50
} ) ;
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
+
47
61
// Drop OpName etc. for inlined functions
48
62
module. debug_names . retain ( |inst| {
49
63
!inst. operands . iter ( ) . any ( |op| {
@@ -204,6 +218,12 @@ fn compute_disallowed_argument_and_return_types(
204
218
( disallowed_argument_types, disallowed_return_types)
205
219
}
206
220
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
+
207
227
fn should_inline (
208
228
disallowed_argument_types : & FxHashSet < Word > ,
209
229
disallowed_return_types : & FxHashSet < Word > ,
0 commit comments