Skip to content

Commit 6b58ff5

Browse files
committed
Usage of atomic counters for llvm code coverage
1 parent 4d941cd commit 6b58ff5

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,9 @@ LLVMRustOptimize(
745745
if (InstrProfileOutput) {
746746
Options.InstrProfileOutput = InstrProfileOutput;
747747
}
748+
// cargo run tests in multhreading mode by default
749+
// so use atomics for coverage counters
750+
Options.Atomic = true;
748751
MPM.addPass(InstrProfiling(Options, false));
749752
}
750753
);

tests/run-make/coverage-llvmir/filecheck.testprog.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ CHECK-SAME: section "llvm.metadata"
3636
CHECK: [[DEFINE_INTERNAL]] { {{.*}} } @_R{{[a-zA-Z0-9_]+}}testprog14will_be_called() unnamed_addr #{{[0-9]+}} {
3737
CHECK-NEXT: start:
3838
CHECK-NOT: [[DEFINE_INTERNAL]]
39-
CHECK: %pgocount = load i64, {{i64\*|ptr}}
39+
CHECK: atomicrmw add ptr
4040
CHECK-SAME: @__profc__R{{[a-zA-Z0-9_]+}}testprog14will_be_called,
4141

4242
CHECK: declare void @llvm.instrprof.increment({{i8\*|ptr}}, i64, i32, i32) #[[LLVM_INSTRPROF_INCREMENT_ATTR:[0-9]+]]

0 commit comments

Comments
 (0)