@@ -245,12 +245,23 @@ pub fn from_fn_attrs(
245
245
}
246
246
}
247
247
248
- // FIXME(eddyb) consolidate these two `inline` calls (and avoid overwrites).
249
- if instance. def . requires_inline ( cx. tcx ) {
250
- inline ( cx, llfn, attributes:: InlineAttr :: Hint ) ;
251
- }
248
+ // Naked functions must never be inlined and must not contain any prologue
249
+ // or epilogue.
250
+ if codegen_fn_attrs. flags . contains ( CodegenFnAttrFlags :: NAKED ) {
251
+ naked ( llfn, true ) ;
252
+ inline ( cx, llfn, attributes:: InlineAttr :: Never ) ;
253
+ } else {
254
+ set_frame_pointer_elimination ( cx, llfn) ;
255
+ set_instrument_function ( cx, llfn) ;
256
+ set_probestack ( cx, llfn) ;
252
257
253
- inline ( cx, llfn, codegen_fn_attrs. inline ) ;
258
+ // FIXME(eddyb) consolidate these two `inline` calls (and avoid overwrites).
259
+ if instance. def . requires_inline ( cx. tcx ) {
260
+ inline ( cx, llfn, attributes:: InlineAttr :: Hint ) ;
261
+ }
262
+
263
+ inline ( cx, llfn, codegen_fn_attrs. inline ) ;
264
+ }
254
265
255
266
// The `uwtable` attribute according to LLVM is:
256
267
//
@@ -272,19 +283,12 @@ pub fn from_fn_attrs(
272
283
attributes:: emit_uwtable ( llfn, true ) ;
273
284
}
274
285
275
- set_frame_pointer_elimination ( cx, llfn) ;
276
- set_instrument_function ( cx, llfn) ;
277
- set_probestack ( cx, llfn) ;
278
-
279
286
if codegen_fn_attrs. flags . contains ( CodegenFnAttrFlags :: COLD ) {
280
287
Attribute :: Cold . apply_llfn ( Function , llfn) ;
281
288
}
282
289
if codegen_fn_attrs. flags . contains ( CodegenFnAttrFlags :: FFI_RETURNS_TWICE ) {
283
290
Attribute :: ReturnsTwice . apply_llfn ( Function , llfn) ;
284
291
}
285
- if codegen_fn_attrs. flags . contains ( CodegenFnAttrFlags :: NAKED ) {
286
- naked ( llfn, true ) ;
287
- }
288
292
if codegen_fn_attrs. flags . contains ( CodegenFnAttrFlags :: ALLOCATOR ) {
289
293
Attribute :: NoAlias . apply_llfn ( llvm:: AttributePlace :: ReturnValue , llfn) ;
290
294
}
0 commit comments