@@ -1679,16 +1679,21 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
16791679 & mut self ,
16801680 fn_name : & ' ll Value ,
16811681 hash : & ' ll Value ,
1682- bitmap_bytes : & ' ll Value ,
1682+ bitmap_bits : & ' ll Value ,
16831683 ) {
1684- debug ! ( "mcdc_parameters() with args ({:?}, {:?}, {:?})" , fn_name, hash, bitmap_bytes) ;
1684+ debug ! ( "mcdc_parameters() with args ({:?}, {:?}, {:?})" , fn_name, hash, bitmap_bits) ;
1685+
1686+ assert ! (
1687+ crate :: llvm_util:: get_version( ) >= ( 19 , 0 , 0 ) ,
1688+ "MCDC intrinsics require LLVM 19 or later"
1689+ ) ;
16851690
16861691 let llfn = unsafe { llvm:: LLVMRustGetInstrProfMCDCParametersIntrinsic ( self . cx ( ) . llmod ) } ;
16871692 let llty = self . cx . type_func (
16881693 & [ self . cx . type_ptr ( ) , self . cx . type_i64 ( ) , self . cx . type_i32 ( ) ] ,
16891694 self . cx . type_void ( ) ,
16901695 ) ;
1691- let args = & [ fn_name, hash, bitmap_bytes ] ;
1696+ let args = & [ fn_name, hash, bitmap_bits ] ;
16921697 let args = self . check_call ( "call" , llty, llfn, args) ;
16931698
16941699 unsafe {
@@ -1708,28 +1713,25 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
17081713 & mut self ,
17091714 fn_name : & ' ll Value ,
17101715 hash : & ' ll Value ,
1711- bitmap_bytes : & ' ll Value ,
17121716 bitmap_index : & ' ll Value ,
17131717 mcdc_temp : & ' ll Value ,
17141718 ) {
17151719 debug ! (
1716- "mcdc_tvbitmap_update() with args ({:?}, {:?}, {:?}, {:?}, {:?})" ,
1717- fn_name, hash, bitmap_bytes, bitmap_index, mcdc_temp
1720+ "mcdc_tvbitmap_update() with args ({:?}, {:?}, {:?}, {:?})" ,
1721+ fn_name, hash, bitmap_index, mcdc_temp
1722+ ) ;
1723+ assert ! (
1724+ crate :: llvm_util:: get_version( ) >= ( 19 , 0 , 0 ) ,
1725+ "MCDC intrinsics require LLVM 19 or later"
17181726 ) ;
17191727
17201728 let llfn =
17211729 unsafe { llvm:: LLVMRustGetInstrProfMCDCTVBitmapUpdateIntrinsic ( self . cx ( ) . llmod ) } ;
17221730 let llty = self . cx . type_func (
1723- & [
1724- self . cx . type_ptr ( ) ,
1725- self . cx . type_i64 ( ) ,
1726- self . cx . type_i32 ( ) ,
1727- self . cx . type_i32 ( ) ,
1728- self . cx . type_ptr ( ) ,
1729- ] ,
1731+ & [ self . cx . type_ptr ( ) , self . cx . type_i64 ( ) , self . cx . type_i32 ( ) , self . cx . type_ptr ( ) ] ,
17301732 self . cx . type_void ( ) ,
17311733 ) ;
1732- let args = & [ fn_name, hash, bitmap_bytes , bitmap_index, mcdc_temp] ;
1734+ let args = & [ fn_name, hash, bitmap_index, mcdc_temp] ;
17331735 let args = self . check_call ( "call" , llty, llfn, args) ;
17341736 unsafe {
17351737 let _ = llvm:: LLVMRustBuildCall (
@@ -1745,41 +1747,15 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
17451747 self . store ( self . const_i32 ( 0 ) , mcdc_temp, self . tcx . data_layout . i32_align . abi ) ;
17461748 }
17471749
1748- pub ( crate ) fn mcdc_condbitmap_update (
1749- & mut self ,
1750- fn_name : & ' ll Value ,
1751- hash : & ' ll Value ,
1752- cond_loc : & ' ll Value ,
1753- mcdc_temp : & ' ll Value ,
1754- bool_value : & ' ll Value ,
1755- ) {
1756- debug ! (
1757- "mcdc_condbitmap_update() with args ({:?}, {:?}, {:?}, {:?}, {:?})" ,
1758- fn_name, hash, cond_loc, mcdc_temp, bool_value
1759- ) ;
1760- let llfn = unsafe { llvm:: LLVMRustGetInstrProfMCDCCondBitmapIntrinsic ( self . cx ( ) . llmod ) } ;
1761- let llty = self . cx . type_func (
1762- & [
1763- self . cx . type_ptr ( ) ,
1764- self . cx . type_i64 ( ) ,
1765- self . cx . type_i32 ( ) ,
1766- self . cx . type_ptr ( ) ,
1767- self . cx . type_i1 ( ) ,
1768- ] ,
1769- self . cx . type_void ( ) ,
1750+ pub ( crate ) fn mcdc_condbitmap_update ( & mut self , cond_index : & ' ll Value , mcdc_temp : & ' ll Value ) {
1751+ debug ! ( "mcdc_condbitmap_update() with args ({:?}, {:?})" , cond_index, mcdc_temp) ;
1752+ assert ! (
1753+ crate :: llvm_util:: get_version( ) >= ( 19 , 0 , 0 ) ,
1754+ "MCDC intrinsics require LLVM 19 or later"
17701755 ) ;
1771- let args = & [ fn_name, hash, cond_loc, mcdc_temp, bool_value] ;
1772- self . check_call ( "call" , llty, llfn, args) ;
1773- unsafe {
1774- let _ = llvm:: LLVMRustBuildCall (
1775- self . llbuilder ,
1776- llty,
1777- llfn,
1778- args. as_ptr ( ) as * const & llvm:: Value ,
1779- args. len ( ) as c_uint ,
1780- [ ] . as_ptr ( ) ,
1781- 0 as c_uint ,
1782- ) ;
1783- }
1756+ let align = self . tcx . data_layout . i32_align . abi ;
1757+ let current_tv_index = self . load ( self . cx . type_i32 ( ) , mcdc_temp, align) ;
1758+ let new_tv_index = self . add ( current_tv_index, cond_index) ;
1759+ self . store ( new_tv_index, mcdc_temp, align) ;
17841760 }
17851761}
0 commit comments