@@ -17,7 +17,7 @@ use rustc_data_structures::small_c_str::SmallCStr;
1717use rustc_hir:: def_id:: DefId ;
1818use rustc_middle:: middle:: codegen_fn_attrs:: CodegenFnAttrs ;
1919use rustc_middle:: ty:: layout:: {
20- FnAbiError , FnAbiOfHelpers , FnAbiRequest , HasTyCtxt , LayoutError , LayoutOfHelpers , TyAndLayout ,
20+ FnAbiError , FnAbiOfHelpers , FnAbiRequest , LayoutError , LayoutOfHelpers , TyAndLayout ,
2121} ;
2222use rustc_middle:: ty:: { self , Instance , Ty , TyCtxt } ;
2323use rustc_sanitizers:: { cfi, kcfi} ;
@@ -27,7 +27,6 @@ use rustc_target::abi::{self, call::FnAbi, Align, Size, WrappingRange};
2727use rustc_target:: spec:: { HasTargetSpec , SanitizerSet , Target } ;
2828use smallvec:: SmallVec ;
2929use std:: borrow:: Cow ;
30- use std:: ffi:: CString ;
3130use std:: iter;
3231use std:: ops:: Deref ;
3332use std:: ptr;
@@ -1705,13 +1704,21 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
17051704 kcfi_bundle
17061705 }
17071706
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
17081716 pub ( crate ) fn mcdc_parameters (
17091717 & mut self ,
17101718 fn_name : & ' ll Value ,
17111719 hash : & ' ll Value ,
17121720 bitmap_bytes : & ' ll Value ,
1713- max_decision_depth : u32 ,
1714- ) -> Vec < & ' ll Value > {
1721+ ) {
17151722 debug ! ( "mcdc_parameters() with args ({:?}, {:?}, {:?})" , fn_name, hash, bitmap_bytes) ;
17161723
17171724 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> {
17241731 let args = & [ fn_name, hash, bitmap_bytes] ;
17251732 let args = self . check_call ( "call" , llty, llfn, args) ;
17261733
1727- let mut cond_bitmaps = vec ! [ ] ;
1728-
17291734 unsafe {
17301735 let _ = llvm:: LLVMRustBuildCall (
17311736 self . llbuilder ,
@@ -1736,23 +1741,7 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
17361741 [ ] . as_ptr ( ) ,
17371742 0 as c_uint ,
17381743 ) ;
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- }
17541744 }
1755- cond_bitmaps
17561745 }
17571746
17581747 pub ( crate ) fn mcdc_tvbitmap_update (
@@ -1794,8 +1783,7 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
17941783 0 as c_uint ,
17951784 ) ;
17961785 }
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 ) ;
17991787 }
18001788
18011789 pub ( crate ) fn mcdc_condbitmap_update (
0 commit comments