@@ -37,6 +37,12 @@ pub fn inline(sess: &Session, module: &mut Module) -> super::Result<()> {
37
37
let mut dropped_ids = FxHashSet :: default ( ) ;
38
38
module. functions . retain ( |f| {
39
39
if should_inline ( & disallowed_argument_types, & disallowed_return_types, f) {
40
+ if has_dont_inline ( f) {
41
+ sess. warn ( & format ! (
42
+ "Function `{}` has `dont_inline` attribute, but need to be inlined because it has illegal argument or return types" ,
43
+ get_name( & get_names( module) , f. def_id( ) . unwrap( ) )
44
+ ) ) ;
45
+ }
40
46
// TODO: We should insert all defined IDs in this function.
41
47
dropped_ids. insert ( f. def_id ( ) . unwrap ( ) ) ;
42
48
false
@@ -202,23 +208,28 @@ fn compute_disallowed_argument_and_return_types(
202
208
( disallowed_argument_types, disallowed_return_types)
203
209
}
204
210
211
+ fn has_dont_inline (
212
+ function : & Function ,
213
+ ) -> bool {
214
+ let def = function. def . as_ref ( ) . unwrap ( ) ;
215
+ let control = def. operands [ 0 ] . unwrap_function_control ( ) ;
216
+ control. contains ( FunctionControl :: DONT_INLINE )
217
+ }
218
+
219
+
205
220
fn should_inline (
206
221
disallowed_argument_types : & FxHashSet < Word > ,
207
222
disallowed_return_types : & FxHashSet < Word > ,
208
223
function : & Function ,
209
224
) -> bool {
210
225
let def = function. def . as_ref ( ) . unwrap ( ) ;
211
226
let control = def. operands [ 0 ] . unwrap_function_control ( ) ;
212
- let should = control. contains ( FunctionControl :: INLINE )
227
+ control. contains ( FunctionControl :: INLINE )
213
228
|| function
214
229
. parameters
215
230
. iter ( )
216
231
. any ( |inst| disallowed_argument_types. contains ( inst. result_type . as_ref ( ) . unwrap ( ) ) )
217
- || disallowed_return_types. contains ( & function. def . as_ref ( ) . unwrap ( ) . result_type . unwrap ( ) ) ;
218
- // if should && control.contains(FunctionControl::DONT_INLINE) {
219
- // println!("should not be inlined!");
220
- // }
221
- should
232
+ || disallowed_return_types. contains ( & function. def . as_ref ( ) . unwrap ( ) . result_type . unwrap ( ) )
222
233
}
223
234
224
235
// This should be more general, but a very common problem is passing an OpAccessChain to an
0 commit comments