@@ -17,7 +17,7 @@ use rustc_data_structures::small_c_str::SmallCStr;
17
17
use rustc_hir:: def_id:: DefId ;
18
18
use rustc_middle:: middle:: codegen_fn_attrs:: CodegenFnAttrs ;
19
19
use rustc_middle:: ty:: layout:: {
20
- FnAbiError , FnAbiOfHelpers , FnAbiRequest , HasTyCtxt , LayoutError , LayoutOfHelpers , TyAndLayout ,
20
+ FnAbiError , FnAbiOfHelpers , FnAbiRequest , LayoutError , LayoutOfHelpers , TyAndLayout ,
21
21
} ;
22
22
use rustc_middle:: ty:: { self , Instance , Ty , TyCtxt } ;
23
23
use rustc_sanitizers:: { cfi, kcfi} ;
@@ -27,7 +27,6 @@ use rustc_target::abi::{self, call::FnAbi, Align, Size, WrappingRange};
27
27
use rustc_target:: spec:: { HasTargetSpec , SanitizerSet , Target } ;
28
28
use smallvec:: SmallVec ;
29
29
use std:: borrow:: Cow ;
30
- use std:: ffi:: CString ;
31
30
use std:: iter;
32
31
use std:: ops:: Deref ;
33
32
use std:: ptr;
@@ -1705,13 +1704,21 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
1705
1704
kcfi_bundle
1706
1705
}
1707
1706
1707
+ /// Emits a call to `llvm.instrprof.mcdc.parameters`.
1708
+ ///
1709
+ /// This doesn't produce any code directly, but is used as input by
1710
+ /// the LLVM pass that handles coverage instrumentation.
1711
+ ///
1712
+ /// (See clang's [`CodeGenPGO::emitMCDCParameters`] for comparison.)
1713
+ ///
1714
+ /// [`CodeGenPGO::emitMCDCParameters`]:
1715
+ /// https://github.com/rust-lang/llvm-project/blob/5399a24/clang/lib/CodeGen/CodeGenPGO.cpp#L1124
1708
1716
pub ( crate ) fn mcdc_parameters (
1709
1717
& mut self ,
1710
1718
fn_name : & ' ll Value ,
1711
1719
hash : & ' ll Value ,
1712
1720
bitmap_bytes : & ' ll Value ,
1713
- max_decision_depth : u32 ,
1714
- ) -> Vec < & ' ll Value > {
1721
+ ) {
1715
1722
debug ! ( "mcdc_parameters() with args ({:?}, {:?}, {:?})" , fn_name, hash, bitmap_bytes) ;
1716
1723
1717
1724
assert ! ( llvm_util:: get_version( ) >= ( 18 , 0 , 0 ) , "MCDC intrinsics require LLVM 18 or later" ) ;
@@ -1724,8 +1731,6 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
1724
1731
let args = & [ fn_name, hash, bitmap_bytes] ;
1725
1732
let args = self . check_call ( "call" , llty, llfn, args) ;
1726
1733
1727
- let mut cond_bitmaps = vec ! [ ] ;
1728
-
1729
1734
unsafe {
1730
1735
let _ = llvm:: LLVMRustBuildCall (
1731
1736
self . llbuilder ,
@@ -1736,23 +1741,7 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
1736
1741
[ ] . as_ptr ( ) ,
1737
1742
0 as c_uint ,
1738
1743
) ;
1739
- // Create condition bitmap named `mcdc.addr`.
1740
- for i in 0 ..=max_decision_depth {
1741
- let mut bx = Builder :: with_cx ( self . cx ) ;
1742
- bx. position_at_start ( llvm:: LLVMGetFirstBasicBlock ( self . llfn ( ) ) ) ;
1743
-
1744
- let name = CString :: new ( format ! ( "mcdc.addr.{i}" ) ) . unwrap ( ) ;
1745
- let cond_bitmap = {
1746
- let alloca =
1747
- llvm:: LLVMBuildAlloca ( bx. llbuilder , bx. cx . type_i32 ( ) , name. as_ptr ( ) ) ;
1748
- llvm:: LLVMSetAlignment ( alloca, 4 ) ;
1749
- alloca
1750
- } ;
1751
- bx. store ( self . const_i32 ( 0 ) , cond_bitmap, self . tcx ( ) . data_layout . i32_align . abi ) ;
1752
- cond_bitmaps. push ( cond_bitmap) ;
1753
- }
1754
1744
}
1755
- cond_bitmaps
1756
1745
}
1757
1746
1758
1747
pub ( crate ) fn mcdc_tvbitmap_update (
@@ -1794,8 +1783,7 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
1794
1783
0 as c_uint ,
1795
1784
) ;
1796
1785
}
1797
- let i32_align = self . tcx ( ) . data_layout . i32_align . abi ;
1798
- self . store ( self . const_i32 ( 0 ) , mcdc_temp, i32_align) ;
1786
+ self . store ( self . const_i32 ( 0 ) , mcdc_temp, Align :: FOUR ) ;
1799
1787
}
1800
1788
1801
1789
pub ( crate ) fn mcdc_condbitmap_update (
0 commit comments