1
+ use crate :: abi:: FnAbiLlvmExt ;
1
2
use crate :: attributes;
2
3
use crate :: common:: Funclet ;
3
4
use crate :: context:: CodegenCx ;
@@ -214,6 +215,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
214
215
fn invoke (
215
216
& mut self ,
216
217
llty : & ' ll Type ,
218
+ fn_abi : Option < & FnAbi < ' tcx , Ty < ' tcx > > > ,
217
219
llfn : & ' ll Value ,
218
220
args : & [ & ' ll Value ] ,
219
221
then : & ' ll BasicBlock ,
@@ -226,7 +228,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
226
228
let bundle = funclet. map ( |funclet| funclet. bundle ( ) ) ;
227
229
let bundle = bundle. as_ref ( ) . map ( |b| & * b. raw ) ;
228
230
229
- unsafe {
231
+ let invoke = unsafe {
230
232
llvm:: LLVMRustBuildInvoke (
231
233
self . llbuilder ,
232
234
llty,
@@ -238,7 +240,11 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
238
240
bundle,
239
241
UNNAMED ,
240
242
)
243
+ } ;
244
+ if let Some ( fn_abi) = fn_abi {
245
+ fn_abi. apply_attrs_callsite ( self , invoke) ;
241
246
}
247
+ invoke
242
248
}
243
249
244
250
fn unreachable ( & mut self ) {
@@ -405,20 +411,17 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
405
411
fn alloca ( & mut self , ty : & ' ll Type , align : Align ) -> & ' ll Value {
406
412
let mut bx = Builder :: with_cx ( self . cx ) ;
407
413
bx. position_at_start ( unsafe { llvm:: LLVMGetFirstBasicBlock ( self . llfn ( ) ) } ) ;
408
- bx. dynamic_alloca ( ty, align)
409
- }
410
-
411
- fn dynamic_alloca ( & mut self , ty : & ' ll Type , align : Align ) -> & ' ll Value {
412
414
unsafe {
413
- let alloca = llvm:: LLVMBuildAlloca ( self . llbuilder , ty, UNNAMED ) ;
415
+ let alloca = llvm:: LLVMBuildAlloca ( bx . llbuilder , ty, UNNAMED ) ;
414
416
llvm:: LLVMSetAlignment ( alloca, align. bytes ( ) as c_uint ) ;
415
417
alloca
416
418
}
417
419
}
418
420
419
- fn array_alloca ( & mut self , ty : & ' ll Type , len : & ' ll Value , align : Align ) -> & ' ll Value {
421
+ fn byte_array_alloca ( & mut self , len : & ' ll Value , align : Align ) -> & ' ll Value {
420
422
unsafe {
421
- let alloca = llvm:: LLVMBuildArrayAlloca ( self . llbuilder , ty, len, UNNAMED ) ;
423
+ let alloca =
424
+ llvm:: LLVMBuildArrayAlloca ( self . llbuilder , self . cx ( ) . type_i8 ( ) , len, UNNAMED ) ;
422
425
llvm:: LLVMSetAlignment ( alloca, align. bytes ( ) as c_uint ) ;
423
426
alloca
424
427
}
@@ -1145,6 +1148,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
1145
1148
fn call (
1146
1149
& mut self ,
1147
1150
llty : & ' ll Type ,
1151
+ fn_abi : Option < & FnAbi < ' tcx , Ty < ' tcx > > > ,
1148
1152
llfn : & ' ll Value ,
1149
1153
args : & [ & ' ll Value ] ,
1150
1154
funclet : Option < & Funclet < ' ll > > ,
@@ -1155,7 +1159,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
1155
1159
let bundle = funclet. map ( |funclet| funclet. bundle ( ) ) ;
1156
1160
let bundle = bundle. as_ref ( ) . map ( |b| & * b. raw ) ;
1157
1161
1158
- unsafe {
1162
+ let call = unsafe {
1159
1163
llvm:: LLVMRustBuildCall (
1160
1164
self . llbuilder ,
1161
1165
llty,
@@ -1164,7 +1168,11 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
1164
1168
args. len ( ) as c_uint ,
1165
1169
bundle,
1166
1170
)
1171
+ } ;
1172
+ if let Some ( fn_abi) = fn_abi {
1173
+ fn_abi. apply_attrs_callsite ( self , call) ;
1167
1174
}
1175
+ call
1168
1176
}
1169
1177
1170
1178
fn zext ( & mut self , val : & ' ll Value , dest_ty : & ' ll Type ) -> & ' ll Value {
@@ -1397,7 +1405,7 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
1397
1405
1398
1406
pub ( crate ) fn call_intrinsic ( & mut self , intrinsic : & str , args : & [ & ' ll Value ] ) -> & ' ll Value {
1399
1407
let ( ty, f) = self . cx . get_intrinsic ( intrinsic) ;
1400
- self . call ( ty, f, args, None )
1408
+ self . call ( ty, None , f, args, None )
1401
1409
}
1402
1410
1403
1411
fn call_lifetime_intrinsic ( & mut self , intrinsic : & str , ptr : & ' ll Value , size : Size ) {
@@ -1459,7 +1467,7 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
1459
1467
format ! ( "llvm.{}.sat.i{}.f{}" , instr, int_width, float_width)
1460
1468
} ;
1461
1469
let f = self . declare_cfn ( & name, llvm:: UnnamedAddr :: No , self . type_func ( & [ src_ty] , dest_ty) ) ;
1462
- self . call ( self . type_func ( & [ src_ty] , dest_ty) , f, & [ val] , None )
1470
+ self . call ( self . type_func ( & [ src_ty] , dest_ty) , None , f, & [ val] , None )
1463
1471
}
1464
1472
1465
1473
pub ( crate ) fn landing_pad (
0 commit comments