@@ -5,17 +5,18 @@ use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue};
5
5
use rustc_codegen_ssa:: mir:: place:: { PlaceRef , PlaceValue } ;
6
6
use rustc_codegen_ssa:: traits:: * ;
7
7
use rustc_codegen_ssa:: MemFlags ;
8
- use rustc_middle:: bug;
9
8
use rustc_middle:: ty:: layout:: LayoutOf ;
10
9
pub use rustc_middle:: ty:: layout:: { FAT_PTR_ADDR , FAT_PTR_EXTRA } ;
11
10
use rustc_middle:: ty:: Ty ;
11
+ use rustc_middle:: { bug, ty} ;
12
12
use rustc_session:: config;
13
13
pub use rustc_target:: abi:: call:: * ;
14
14
use rustc_target:: abi:: { self , HasDataLayout , Int , Size } ;
15
15
pub use rustc_target:: spec:: abi:: Abi ;
16
16
use rustc_target:: spec:: SanitizerSet ;
17
17
use smallvec:: SmallVec ;
18
18
19
+ use crate :: attributes:: llfn_attrs_from_instance;
19
20
use crate :: builder:: Builder ;
20
21
use crate :: context:: CodegenCx ;
21
22
use crate :: llvm:: { self , Attribute , AttributePlace } ;
@@ -310,7 +311,16 @@ pub trait FnAbiLlvmExt<'ll, 'tcx> {
310
311
fn llvm_type ( & self , cx : & CodegenCx < ' ll , ' tcx > ) -> & ' ll Type ;
311
312
fn ptr_to_llvm_type ( & self , cx : & CodegenCx < ' ll , ' tcx > ) -> & ' ll Type ;
312
313
fn llvm_cconv ( & self ) -> llvm:: CallConv ;
313
- fn apply_attrs_llfn ( & self , cx : & CodegenCx < ' ll , ' tcx > , llfn : & ' ll Value ) ;
314
+
315
+ /// Apply attributes to a function declaration/definition.
316
+ fn apply_attrs_llfn (
317
+ & self ,
318
+ cx : & CodegenCx < ' ll , ' tcx > ,
319
+ llfn : & ' ll Value ,
320
+ instance : Option < ty:: Instance < ' tcx > > ,
321
+ ) ;
322
+
323
+ /// Apply attributes to a function call.
314
324
fn apply_attrs_callsite ( & self , bx : & mut Builder < ' _ , ' ll , ' tcx > , callsite : & ' ll Value ) ;
315
325
}
316
326
@@ -396,7 +406,12 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
396
406
self . conv . into ( )
397
407
}
398
408
399
- fn apply_attrs_llfn ( & self , cx : & CodegenCx < ' ll , ' tcx > , llfn : & ' ll Value ) {
409
+ fn apply_attrs_llfn (
410
+ & self ,
411
+ cx : & CodegenCx < ' ll , ' tcx > ,
412
+ llfn : & ' ll Value ,
413
+ instance : Option < ty:: Instance < ' tcx > > ,
414
+ ) {
400
415
let mut func_attrs = SmallVec :: < [ _ ; 3 ] > :: new ( ) ;
401
416
if self . ret . layout . abi . is_uninhabited ( ) {
402
417
func_attrs. push ( llvm:: AttributeKind :: NoReturn . create_attr ( cx. llcx ) ) ;
@@ -477,6 +492,11 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
477
492
}
478
493
}
479
494
}
495
+
496
+ // If the declaration has an associated instance, compute extra attributes based on that.
497
+ if let Some ( instance) = instance {
498
+ llfn_attrs_from_instance ( cx, llfn, instance) ;
499
+ }
480
500
}
481
501
482
502
fn apply_attrs_callsite ( & self , bx : & mut Builder < ' _ , ' ll , ' tcx > , callsite : & ' ll Value ) {
0 commit comments