@@ -1679,16 +1679,21 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
1679
1679
& mut self ,
1680
1680
fn_name : & ' ll Value ,
1681
1681
hash : & ' ll Value ,
1682
- bitmap_bytes : & ' ll Value ,
1682
+ bitmap_bits : & ' ll Value ,
1683
1683
) {
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
+ ) ;
1685
1690
1686
1691
let llfn = unsafe { llvm:: LLVMRustGetInstrProfMCDCParametersIntrinsic ( self . cx ( ) . llmod ) } ;
1687
1692
let llty = self . cx . type_func (
1688
1693
& [ self . cx . type_ptr ( ) , self . cx . type_i64 ( ) , self . cx . type_i32 ( ) ] ,
1689
1694
self . cx . type_void ( ) ,
1690
1695
) ;
1691
- let args = & [ fn_name, hash, bitmap_bytes ] ;
1696
+ let args = & [ fn_name, hash, bitmap_bits ] ;
1692
1697
let args = self . check_call ( "call" , llty, llfn, args) ;
1693
1698
1694
1699
unsafe {
@@ -1708,28 +1713,25 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
1708
1713
& mut self ,
1709
1714
fn_name : & ' ll Value ,
1710
1715
hash : & ' ll Value ,
1711
- bitmap_bytes : & ' ll Value ,
1712
1716
bitmap_index : & ' ll Value ,
1713
1717
mcdc_temp : & ' ll Value ,
1714
1718
) {
1715
1719
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"
1718
1726
) ;
1719
1727
1720
1728
let llfn =
1721
1729
unsafe { llvm:: LLVMRustGetInstrProfMCDCTVBitmapUpdateIntrinsic ( self . cx ( ) . llmod ) } ;
1722
1730
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 ( ) ] ,
1730
1732
self . cx . type_void ( ) ,
1731
1733
) ;
1732
- let args = & [ fn_name, hash, bitmap_bytes , bitmap_index, mcdc_temp] ;
1734
+ let args = & [ fn_name, hash, bitmap_index, mcdc_temp] ;
1733
1735
let args = self . check_call ( "call" , llty, llfn, args) ;
1734
1736
unsafe {
1735
1737
let _ = llvm:: LLVMRustBuildCall (
@@ -1745,41 +1747,15 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
1745
1747
self . store ( self . const_i32 ( 0 ) , mcdc_temp, self . tcx . data_layout . i32_align . abi ) ;
1746
1748
}
1747
1749
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"
1770
1755
) ;
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) ;
1784
1760
}
1785
1761
}
0 commit comments