diff options
| author | Evgeniy A. Dushistov <dushistov@mail.ru> | 2023-05-11 17:35:01 +0300 |
|---|---|---|
| committer | Evgeniy A. Dushistov <dushistov@mail.ru> | 2023-05-12 01:40:04 +0300 |
| commit | 6b58ff5cdf47da9460871a87cf43e5e8adfab9a8 (patch) | |
| tree | b9defb0db0823064fa71cd9093b99301ffe44967 | |
| parent | 4d941cd9812891af3b83dd4de64aa7d8ee99641a (diff) | |
| download | rust-6b58ff5cdf47da9460871a87cf43e5e8adfab9a8.tar.gz rust-6b58ff5cdf47da9460871a87cf43e5e8adfab9a8.zip | |
Usage of atomic counters for llvm code coverage
| -rw-r--r-- | compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp | 3 | ||||
| -rw-r--r-- | tests/run-make/coverage-llvmir/filecheck.testprog.txt | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index 5ec3b95225d..7b774d6865c 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -745,6 +745,9 @@ LLVMRustOptimize( if (InstrProfileOutput) { Options.InstrProfileOutput = InstrProfileOutput; } + // cargo run tests in multhreading mode by default + // so use atomics for coverage counters + Options.Atomic = true; MPM.addPass(InstrProfiling(Options, false)); } ); diff --git a/tests/run-make/coverage-llvmir/filecheck.testprog.txt b/tests/run-make/coverage-llvmir/filecheck.testprog.txt index c943261d799..b3a8808df05 100644 --- a/tests/run-make/coverage-llvmir/filecheck.testprog.txt +++ b/tests/run-make/coverage-llvmir/filecheck.testprog.txt @@ -36,7 +36,7 @@ CHECK-SAME: section "llvm.metadata" CHECK: [[DEFINE_INTERNAL]] { {{.*}} } @_R{{[a-zA-Z0-9_]+}}testprog14will_be_called() unnamed_addr #{{[0-9]+}} { CHECK-NEXT: start: CHECK-NOT: [[DEFINE_INTERNAL]] -CHECK: %pgocount = load i64, {{i64\*|ptr}} +CHECK: atomicrmw add ptr CHECK-SAME: @__profc__R{{[a-zA-Z0-9_]+}}testprog14will_be_called, CHECK: declare void @llvm.instrprof.increment({{i8\*|ptr}}, i64, i32, i32) #[[LLVM_INSTRPROF_INCREMENT_ATTR:[0-9]+]] |
