@@ -30,6 +30,7 @@ use crate::abi::FnAbiLlvmExt;
3030use crate :: attributes;
3131use crate :: common:: Funclet ;
3232use crate :: context:: CodegenCx ;
33+ use crate :: llvm:: debuginfo:: DILocation ;
3334use crate :: llvm:: { self , AtomicOrdering , AtomicRmwBinOp , BasicBlock , False , True } ;
3435use crate :: type_:: Type ;
3536use crate :: type_of:: LayoutLlvmExt ;
@@ -234,6 +235,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
234235 catch : & ' ll BasicBlock ,
235236 funclet : Option < & Funclet < ' ll > > ,
236237 instance : Option < Instance < ' tcx > > ,
238+ dbg_loc : Option < & ' ll DILocation > ,
237239 ) -> & ' ll Value {
238240 debug ! ( "invoke {:?} with args ({:?})" , llfn, args) ;
239241
@@ -245,7 +247,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
245247 }
246248
247249 // Emit CFI pointer type membership test
248- self . cfi_type_test ( fn_attrs, fn_abi, instance, llfn) ;
250+ self . cfi_type_test ( fn_attrs, fn_abi, instance, dbg_loc , llfn) ;
249251
250252 // Emit KCFI operand bundle
251253 let kcfi_bundle = self . kcfi_operand_bundle ( fn_attrs, fn_abi, instance, llfn) ;
@@ -1172,6 +1174,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
11721174 args : & [ & ' ll Value ] ,
11731175 funclet : Option < & Funclet < ' ll > > ,
11741176 instance : Option < Instance < ' tcx > > ,
1177+ dbg_loc : Option < & ' ll DILocation > ,
11751178 ) -> & ' ll Value {
11761179 debug ! ( "call {:?} with args ({:?})" , llfn, args) ;
11771180
@@ -1183,7 +1186,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
11831186 }
11841187
11851188 // Emit CFI pointer type membership test
1186- self . cfi_type_test ( fn_attrs, fn_abi, instance, llfn) ;
1189+ self . cfi_type_test ( fn_attrs, fn_abi, instance, dbg_loc , llfn) ;
11871190
11881191 // Emit KCFI operand bundle
11891192 let kcfi_bundle = self . kcfi_operand_bundle ( fn_attrs, fn_abi, instance, llfn) ;
@@ -1414,7 +1417,7 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
14141417
14151418 pub ( crate ) fn call_intrinsic ( & mut self , intrinsic : & str , args : & [ & ' ll Value ] ) -> & ' ll Value {
14161419 let ( ty, f) = self . cx . get_intrinsic ( intrinsic) ;
1417- self . call ( ty, None , None , f, args, None , None )
1420+ self . call ( ty, None , None , f, args, None , None , None )
14181421 }
14191422
14201423 fn call_lifetime_intrinsic ( & mut self , intrinsic : & str , ptr : & ' ll Value , size : Size ) {
@@ -1472,7 +1475,7 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
14721475 format ! ( "llvm.{instr}.sat.i{int_width}.f{float_width}" )
14731476 } ;
14741477 let f = self . declare_cfn ( & name, llvm:: UnnamedAddr :: No , self . type_func ( & [ src_ty] , dest_ty) ) ;
1475- self . call ( self . type_func ( & [ src_ty] , dest_ty) , None , None , f, & [ val] , None , None )
1478+ self . call ( self . type_func ( & [ src_ty] , dest_ty) , None , None , f, & [ val] , None , None , None )
14761479 }
14771480
14781481 pub ( crate ) fn landing_pad (
@@ -1501,6 +1504,7 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
15011504 indirect_dest : & [ & ' ll BasicBlock ] ,
15021505 funclet : Option < & Funclet < ' ll > > ,
15031506 instance : Option < Instance < ' tcx > > ,
1507+ dbg_loc : Option < & ' ll DILocation > ,
15041508 ) -> & ' ll Value {
15051509 debug ! ( "invoke {:?} with args ({:?})" , llfn, args) ;
15061510
@@ -1512,7 +1516,7 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
15121516 }
15131517
15141518 // Emit CFI pointer type membership test
1515- self . cfi_type_test ( fn_attrs, fn_abi, instance, llfn) ;
1519+ self . cfi_type_test ( fn_attrs, fn_abi, instance, dbg_loc , llfn) ;
15161520
15171521 // Emit KCFI operand bundle
15181522 let kcfi_bundle = self . kcfi_operand_bundle ( fn_attrs, fn_abi, instance, llfn) ;
@@ -1547,6 +1551,7 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
15471551 fn_attrs : Option < & CodegenFnAttrs > ,
15481552 fn_abi : Option < & FnAbi < ' tcx , Ty < ' tcx > > > ,
15491553 instance : Option < Instance < ' tcx > > ,
1554+ dbg_loc : Option < & ' ll DILocation > ,
15501555 llfn : & ' ll Value ,
15511556 ) {
15521557 let is_indirect_call = unsafe { llvm:: LLVMRustIsNonGVFunctionPointerTy ( llfn) } ;
@@ -1582,10 +1587,16 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
15821587 self . cond_br ( cond, bb_pass, bb_fail) ;
15831588
15841589 self . switch_to_block ( bb_fail) ;
1590+ if let Some ( dbg_loc) = dbg_loc {
1591+ self . set_dbg_loc ( dbg_loc) ;
1592+ }
15851593 self . abort ( ) ;
15861594 self . unreachable ( ) ;
15871595
15881596 self . switch_to_block ( bb_pass) ;
1597+ if let Some ( dbg_loc) = dbg_loc {
1598+ self . set_dbg_loc ( dbg_loc) ;
1599+ }
15891600 }
15901601 }
15911602
0 commit comments