@@ -1165,39 +1165,6 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
1165
1165
self . call_lifetime_intrinsic ( "llvm.lifetime.end.p0i8" , ptr, size) ;
1166
1166
}
1167
1167
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
-
1201
1168
fn call (
1202
1169
& mut self ,
1203
1170
llty : & ' ll Type ,
@@ -1667,6 +1634,18 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
1667
1634
kcfi_bundle
1668
1635
}
1669
1636
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
+
1670
1649
/// Emits a call to `llvm.instrprof.mcdc.parameters`.
1671
1650
///
1672
1651
/// 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> {
1676
1655
///
1677
1656
/// [`CodeGenPGO::emitMCDCParameters`]:
1678
1657
/// https://github.com/rust-lang/llvm-project/blob/5399a24/clang/lib/CodeGen/CodeGenPGO.cpp#L1124
1658
+ #[ instrument( level = "debug" , skip( self ) ) ]
1679
1659
pub ( crate ) fn mcdc_parameters (
1680
1660
& mut self ,
1681
1661
fn_name : & ' ll Value ,
1682
1662
hash : & ' ll Value ,
1683
1663
bitmap_bits : & ' ll Value ,
1684
1664
) {
1685
- debug ! ( "mcdc_parameters() with args ({:?}, {:?}, {:?})" , fn_name, hash, bitmap_bits) ;
1686
-
1687
1665
assert ! (
1688
1666
crate :: llvm_util:: get_version( ) >= ( 19 , 0 , 0 ) ,
1689
1667
"MCDC intrinsics require LLVM 19 or later"
1690
1668
) ;
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] ) ;
1711
1670
}
1712
1671
1672
+ #[ instrument( level = "debug" , skip( self ) ) ]
1713
1673
pub ( crate ) fn mcdc_tvbitmap_update (
1714
1674
& mut self ,
1715
1675
fn_name : & ' ll Value ,
1716
1676
hash : & ' ll Value ,
1717
1677
bitmap_index : & ' ll Value ,
1718
1678
mcdc_temp : & ' ll Value ,
1719
1679
) {
1720
- debug ! (
1721
- "mcdc_tvbitmap_update() with args ({:?}, {:?}, {:?}, {:?})" ,
1722
- fn_name, hash, bitmap_index, mcdc_temp
1723
- ) ;
1724
1680
assert ! (
1725
1681
crate :: llvm_util:: get_version( ) >= ( 19 , 0 , 0 ) ,
1726
1682
"MCDC intrinsics require LLVM 19 or later"
1727
1683
) ;
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
- ) ;
1735
1684
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 ) {
1748
1690
self . store ( self . const_i32 ( 0 ) , mcdc_temp, self . tcx . data_layout . i32_align . abi ) ;
1749
1691
}
1750
1692
1693
+ #[ instrument( level = "debug" , skip( self ) ) ]
1751
1694
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) ;
1753
1695
assert ! (
1754
1696
crate :: llvm_util:: get_version( ) >= ( 19 , 0 , 0 ) ,
1755
1697
"MCDC intrinsics require LLVM 19 or later"
0 commit comments