1
+ use crate :: abi:: FnAbiLlvmExt ;
1
2
use crate :: common:: Funclet ;
2
3
use crate :: context:: CodegenCx ;
3
4
use crate :: llvm:: { self , BasicBlock , False } ;
@@ -18,6 +19,7 @@ use rustc_hir::def_id::DefId;
18
19
use rustc_middle:: ty:: layout:: TyAndLayout ;
19
20
use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
20
21
use rustc_span:: Span ;
22
+ use rustc_target:: abi:: call:: FnAbi ;
21
23
use rustc_target:: abi:: { self , Align , Size } ;
22
24
use rustc_target:: spec:: { HasTargetSpec , Target } ;
23
25
use std:: borrow:: Cow ;
@@ -209,14 +211,15 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
209
211
then : & ' ll BasicBlock ,
210
212
catch : & ' ll BasicBlock ,
211
213
funclet : Option < & Funclet < ' ll > > ,
214
+ fn_abi_for_attrs : Option < & FnAbi < ' tcx , Ty < ' tcx > > > ,
212
215
) -> & ' ll Value {
213
216
debug ! ( "invoke {:?} with args ({:?})" , llfn, args) ;
214
217
215
218
let args = self . check_call ( "invoke" , llfn, args) ;
216
219
let bundle = funclet. map ( |funclet| funclet. bundle ( ) ) ;
217
220
let bundle = bundle. as_ref ( ) . map ( |b| & * b. raw ) ;
218
221
219
- unsafe {
222
+ let invoke = unsafe {
220
223
llvm:: LLVMRustBuildInvoke (
221
224
self . llbuilder ,
222
225
llfn,
@@ -227,7 +230,11 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
227
230
bundle,
228
231
UNNAMED ,
229
232
)
233
+ } ;
234
+ if let Some ( fn_abi) = fn_abi_for_attrs {
235
+ fn_abi. apply_attrs_callsite ( self , invoke) ;
230
236
}
237
+ invoke
231
238
}
232
239
233
240
fn unreachable ( & mut self ) {
@@ -374,7 +381,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
374
381
} ;
375
382
376
383
let intrinsic = self . get_intrinsic ( & name) ;
377
- let res = self . call ( intrinsic, & [ lhs, rhs] , None ) ;
384
+ let res = self . call ( intrinsic, & [ lhs, rhs] , None , None ) ;
378
385
( self . extract_value ( res, 0 ) , self . extract_value ( res, 1 ) )
379
386
}
380
387
@@ -684,7 +691,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
684
691
let int_width = self . cx . int_width ( dest_ty) ;
685
692
let name = format ! ( "llvm.fptoui.sat.i{}.f{}" , int_width, float_width) ;
686
693
let intrinsic = self . get_intrinsic ( & name) ;
687
- return Some ( self . call ( intrinsic, & [ val] , None ) ) ;
694
+ return Some ( self . call ( intrinsic, & [ val] , None , None ) ) ;
688
695
}
689
696
690
697
None
@@ -697,7 +704,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
697
704
let int_width = self . cx . int_width ( dest_ty) ;
698
705
let name = format ! ( "llvm.fptosi.sat.i{}.f{}" , int_width, float_width) ;
699
706
let intrinsic = self . get_intrinsic ( & name) ;
700
- return Some ( self . call ( intrinsic, & [ val] , None ) ) ;
707
+ return Some ( self . call ( intrinsic, & [ val] , None , None ) ) ;
701
708
}
702
709
703
710
None
@@ -732,7 +739,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
732
739
} ;
733
740
if let Some ( name) = name {
734
741
let intrinsic = self . get_intrinsic ( name) ;
735
- return self . call ( intrinsic, & [ val] , None ) ;
742
+ return self . call ( intrinsic, & [ val] , None , None ) ;
736
743
}
737
744
}
738
745
}
@@ -755,7 +762,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
755
762
} ;
756
763
if let Some ( name) = name {
757
764
let intrinsic = self . get_intrinsic ( name) ;
758
- return self . call ( intrinsic, & [ val] , None ) ;
765
+ return self . call ( intrinsic, & [ val] , None , None ) ;
759
766
}
760
767
}
761
768
}
@@ -1130,22 +1137,27 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
1130
1137
llfn : & ' ll Value ,
1131
1138
args : & [ & ' ll Value ] ,
1132
1139
funclet : Option < & Funclet < ' ll > > ,
1140
+ fn_abi_for_attrs : Option < & FnAbi < ' tcx , Ty < ' tcx > > > ,
1133
1141
) -> & ' ll Value {
1134
1142
debug ! ( "call {:?} with args ({:?})" , llfn, args) ;
1135
1143
1136
1144
let args = self . check_call ( "call" , llfn, args) ;
1137
1145
let bundle = funclet. map ( |funclet| funclet. bundle ( ) ) ;
1138
1146
let bundle = bundle. as_ref ( ) . map ( |b| & * b. raw ) ;
1139
1147
1140
- unsafe {
1148
+ let call = unsafe {
1141
1149
llvm:: LLVMRustBuildCall (
1142
1150
self . llbuilder ,
1143
1151
llfn,
1144
1152
args. as_ptr ( ) as * const & llvm:: Value ,
1145
1153
args. len ( ) as c_uint ,
1146
1154
bundle,
1147
1155
)
1156
+ } ;
1157
+ if let Some ( fn_abi) = fn_abi_for_attrs {
1158
+ fn_abi. apply_attrs_callsite ( self , call) ;
1148
1159
}
1160
+ call
1149
1161
}
1150
1162
1151
1163
fn zext ( & mut self , val : & ' ll Value , dest_ty : & ' ll Type ) -> & ' ll Value {
@@ -1374,7 +1386,7 @@ impl Builder<'a, 'll, 'tcx> {
1374
1386
let lifetime_intrinsic = self . cx . get_intrinsic ( intrinsic) ;
1375
1387
1376
1388
let ptr = self . pointercast ( ptr, self . cx . type_i8p ( ) ) ;
1377
- self . call ( lifetime_intrinsic, & [ self . cx . const_u64 ( size) , ptr] , None ) ;
1389
+ self . call ( lifetime_intrinsic, & [ self . cx . const_u64 ( size) , ptr] , None , None ) ;
1378
1390
}
1379
1391
1380
1392
pub ( crate ) fn phi (
0 commit comments