@@ -1165,39 +1165,6 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
11651165        self . call_lifetime_intrinsic ( "llvm.lifetime.end.p0i8" ,  ptr,  size) ; 
11661166    } 
11671167
1168-     fn  instrprof_increment ( 
1169-         & mut  self , 
1170-         fn_name :  & ' ll  Value , 
1171-         hash :  & ' ll  Value , 
1172-         num_counters :  & ' ll  Value , 
1173-         index :  & ' ll  Value , 
1174-     )  { 
1175-         debug ! ( 
1176-             "instrprof_increment() with args ({:?}, {:?}, {:?}, {:?})" , 
1177-             fn_name,  hash,  num_counters,  index
1178-         ) ; 
1179- 
1180-         let  llfn = unsafe  {  llvm:: LLVMRustGetInstrProfIncrementIntrinsic ( self . cx ( ) . llmod )  } ; 
1181-         let  llty = self . cx . type_func ( 
1182-             & [ self . cx . type_ptr ( ) ,  self . cx . type_i64 ( ) ,  self . cx . type_i32 ( ) ,  self . cx . type_i32 ( ) ] , 
1183-             self . cx . type_void ( ) , 
1184-         ) ; 
1185-         let  args = & [ fn_name,  hash,  num_counters,  index] ; 
1186-         let  args = self . check_call ( "call" ,  llty,  llfn,  args) ; 
1187- 
1188-         unsafe  { 
1189-             let  _ = llvm:: LLVMRustBuildCall ( 
1190-                 self . llbuilder , 
1191-                 llty, 
1192-                 llfn, 
1193-                 args. as_ptr ( )  as  * const  & llvm:: Value , 
1194-                 args. len ( )  as  c_uint , 
1195-                 [ ] . as_ptr ( ) , 
1196-                 0  as  c_uint , 
1197-             ) ; 
1198-         } 
1199-     } 
1200- 
12011168    fn  call ( 
12021169        & mut  self , 
12031170        llty :  & ' ll  Type , 
@@ -1667,6 +1634,18 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
16671634        kcfi_bundle
16681635    } 
16691636
1637+     /// Emits a call to `llvm.instrprof.increment`. Used by coverage instrumentation. 
1638+      #[ instrument( level = "debug" ,  skip( self ) ) ]  
1639+     pub ( crate )  fn  instrprof_increment ( 
1640+         & mut  self , 
1641+         fn_name :  & ' ll  Value , 
1642+         hash :  & ' ll  Value , 
1643+         num_counters :  & ' ll  Value , 
1644+         index :  & ' ll  Value , 
1645+     )  { 
1646+         self . call_intrinsic ( "llvm.instrprof.increment" ,  & [ fn_name,  hash,  num_counters,  index] ) ; 
1647+     } 
1648+ 
16701649    /// Emits a call to `llvm.instrprof.mcdc.parameters`. 
16711650     /// 
16721651     /// This doesn't produce any code directly, but is used as input by 
@@ -1676,80 +1655,43 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
16761655     /// 
16771656     /// [`CodeGenPGO::emitMCDCParameters`]: 
16781657     ///     https://github.com/rust-lang/llvm-project/blob/5399a24/clang/lib/CodeGen/CodeGenPGO.cpp#L1124 
1658+      #[ instrument( level = "debug" ,  skip( self ) ) ]  
16791659    pub ( crate )  fn  mcdc_parameters ( 
16801660        & mut  self , 
16811661        fn_name :  & ' ll  Value , 
16821662        hash :  & ' ll  Value , 
16831663        bitmap_bits :  & ' ll  Value , 
16841664    )  { 
1685-         debug ! ( "mcdc_parameters() with args ({:?}, {:?}, {:?})" ,  fn_name,  hash,  bitmap_bits) ; 
1686- 
16871665        assert ! ( 
16881666            crate :: llvm_util:: get_version( )  >= ( 19 ,  0 ,  0 ) , 
16891667            "MCDC intrinsics require LLVM 19 or later" 
16901668        ) ; 
1691- 
1692-         let  llfn = unsafe  {  llvm:: LLVMRustGetInstrProfMCDCParametersIntrinsic ( self . cx ( ) . llmod )  } ; 
1693-         let  llty = self . cx . type_func ( 
1694-             & [ self . cx . type_ptr ( ) ,  self . cx . type_i64 ( ) ,  self . cx . type_i32 ( ) ] , 
1695-             self . cx . type_void ( ) , 
1696-         ) ; 
1697-         let  args = & [ fn_name,  hash,  bitmap_bits] ; 
1698-         let  args = self . check_call ( "call" ,  llty,  llfn,  args) ; 
1699- 
1700-         unsafe  { 
1701-             let  _ = llvm:: LLVMRustBuildCall ( 
1702-                 self . llbuilder , 
1703-                 llty, 
1704-                 llfn, 
1705-                 args. as_ptr ( )  as  * const  & llvm:: Value , 
1706-                 args. len ( )  as  c_uint , 
1707-                 [ ] . as_ptr ( ) , 
1708-                 0  as  c_uint , 
1709-             ) ; 
1710-         } 
1669+         self . call_intrinsic ( "llvm.instrprof.mcdc.parameters" ,  & [ fn_name,  hash,  bitmap_bits] ) ; 
17111670    } 
17121671
1672+     #[ instrument( level = "debug" ,  skip( self ) ) ]  
17131673    pub ( crate )  fn  mcdc_tvbitmap_update ( 
17141674        & mut  self , 
17151675        fn_name :  & ' ll  Value , 
17161676        hash :  & ' ll  Value , 
17171677        bitmap_index :  & ' ll  Value , 
17181678        mcdc_temp :  & ' ll  Value , 
17191679    )  { 
1720-         debug ! ( 
1721-             "mcdc_tvbitmap_update() with args ({:?}, {:?}, {:?}, {:?})" , 
1722-             fn_name,  hash,  bitmap_index,  mcdc_temp
1723-         ) ; 
17241680        assert ! ( 
17251681            crate :: llvm_util:: get_version( )  >= ( 19 ,  0 ,  0 ) , 
17261682            "MCDC intrinsics require LLVM 19 or later" 
17271683        ) ; 
1728- 
1729-         let  llfn =
1730-             unsafe  {  llvm:: LLVMRustGetInstrProfMCDCTVBitmapUpdateIntrinsic ( self . cx ( ) . llmod )  } ; 
1731-         let  llty = self . cx . type_func ( 
1732-             & [ self . cx . type_ptr ( ) ,  self . cx . type_i64 ( ) ,  self . cx . type_i32 ( ) ,  self . cx . type_ptr ( ) ] , 
1733-             self . cx . type_void ( ) , 
1734-         ) ; 
17351684        let  args = & [ fn_name,  hash,  bitmap_index,  mcdc_temp] ; 
1736-         let  args = self . check_call ( "call" ,  llty,  llfn,  args) ; 
1737-         unsafe  { 
1738-             let  _ = llvm:: LLVMRustBuildCall ( 
1739-                 self . llbuilder , 
1740-                 llty, 
1741-                 llfn, 
1742-                 args. as_ptr ( )  as  * const  & llvm:: Value , 
1743-                 args. len ( )  as  c_uint , 
1744-                 [ ] . as_ptr ( ) , 
1745-                 0  as  c_uint , 
1746-             ) ; 
1747-         } 
1685+         self . call_intrinsic ( "llvm.instrprof.mcdc.tvbitmap.update" ,  args) ; 
1686+     } 
1687+ 
1688+     #[ instrument( level = "debug" ,  skip( self ) ) ]  
1689+     pub ( crate )  fn  mcdc_condbitmap_reset ( & mut  self ,  mcdc_temp :  & ' ll  Value )  { 
17481690        self . store ( self . const_i32 ( 0 ) ,  mcdc_temp,  self . tcx . data_layout . i32_align . abi ) ; 
17491691    } 
17501692
1693+     #[ instrument( level = "debug" ,  skip( self ) ) ]  
17511694    pub ( crate )  fn  mcdc_condbitmap_update ( & mut  self ,  cond_index :  & ' ll  Value ,  mcdc_temp :  & ' ll  Value )  { 
1752-         debug ! ( "mcdc_condbitmap_update() with args ({:?}, {:?})" ,  cond_index,  mcdc_temp) ; 
17531695        assert ! ( 
17541696            crate :: llvm_util:: get_version( )  >= ( 19 ,  0 ,  0 ) , 
17551697            "MCDC intrinsics require LLVM 19 or later" 
0 commit comments