Skip to content

Commit 4923e85

Browse files
committed
coverage: Emit llvm.instrprof.increment using the normal helper method
1 parent a93c171 commit 4923e85

File tree

3 files changed

+2
-36
lines changed

3 files changed

+2
-36
lines changed

compiler/rustc_codegen_llvm/src/builder.rs

+2-24
Original file line numberDiff line numberDiff line change
@@ -1165,37 +1165,15 @@ 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+
#[instrument(level = "debug", skip(self))]
11681169
fn instrprof_increment(
11691170
&mut self,
11701171
fn_name: &'ll Value,
11711172
hash: &'ll Value,
11721173
num_counters: &'ll Value,
11731174
index: &'ll Value,
11741175
) {
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-
}
1176+
self.call_intrinsic("llvm.instrprof.increment", &[fn_name, hash, num_counters, index]);
11991177
}
12001178

12011179
fn call(

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1615,7 +1615,6 @@ unsafe extern "C" {
16151615
pub fn LLVMRustSetAllowReassoc(Instr: &Value);
16161616

16171617
// Miscellaneous instructions
1618-
pub fn LLVMRustGetInstrProfIncrementIntrinsic(M: &Module) -> &Value;
16191618
pub fn LLVMRustGetInstrProfMCDCParametersIntrinsic(M: &Module) -> &Value;
16201619
pub fn LLVMRustGetInstrProfMCDCTVBitmapUpdateIntrinsic(M: &Module) -> &Value;
16211620

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

-11
Original file line numberDiff line numberDiff line change
@@ -1531,17 +1531,6 @@ extern "C" LLVMValueRef LLVMRustBuildCall(LLVMBuilderRef B, LLVMTypeRef Ty,
15311531
ArrayRef<OperandBundleDef>(OpBundles)));
15321532
}
15331533

1534-
extern "C" LLVMValueRef
1535-
LLVMRustGetInstrProfIncrementIntrinsic(LLVMModuleRef M) {
1536-
#if LLVM_VERSION_GE(20, 0)
1537-
return wrap(llvm::Intrinsic::getOrInsertDeclaration(
1538-
unwrap(M), llvm::Intrinsic::instrprof_increment));
1539-
#else
1540-
return wrap(llvm::Intrinsic::getDeclaration(
1541-
unwrap(M), llvm::Intrinsic::instrprof_increment));
1542-
#endif
1543-
}
1544-
15451534
extern "C" LLVMValueRef
15461535
LLVMRustGetInstrProfMCDCParametersIntrinsic(LLVMModuleRef M) {
15471536
#if LLVM_VERSION_LT(19, 0)

0 commit comments

Comments
 (0)