Skip to content

Commit d0f5a49

Browse files
authored
[Support] Support debug counters in non-assertion builds (#170468)
This enables the use of debug counters in (non-assertion) release builds. This is useful to enable debugging without having to switch to an assertion-enabled build, which may not always be easy. After some recent improvements, always supporting debug counters no longer has measurable overhead.
1 parent 5ab8c3a commit d0f5a49

File tree

21 files changed

+0
-38
lines changed

21 files changed

+0
-38
lines changed

llvm/include/llvm/Support/DebugCounter.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,9 @@ class DebugCounter {
109109
LLVM_ABI static bool shouldExecuteImpl(CounterInfo &Counter);
110110

111111
inline static bool shouldExecute(CounterInfo &Counter) {
112-
// Compile to nothing when debugging is off
113-
#ifdef NDEBUG
114-
return true;
115-
#else
116112
if (!Counter.Active)
117113
return true;
118114
return shouldExecuteImpl(Counter);
119-
#endif
120115
}
121116

122117
// Return true if a given counter had values set (either programatically or on

llvm/lib/Support/DebugCounter.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,6 @@ DebugCounter &DebugCounter::instance() { return *Owner; }
185185
void DebugCounter::push_back(const std::string &Val) {
186186
if (Val.empty())
187187
return;
188-
#ifdef NDEBUG
189-
// isCountingEnabled is hardcoded to false in NDEBUG.
190-
errs() << "Requested --debug-counter in LLVM build without assertions. This "
191-
"is a no-op.\n";
192-
#endif
193188

194189
// The strings should come in as counter=chunk_list
195190
auto CounterPair = StringRef(Val).split('=');

llvm/test/Analysis/ValueTracking/assume-queries-counter.ll

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2-
; REQUIRES: asserts
32

43
; RUN: opt < %s -passes=instcombine --debug-counter=assume-queries-counter=0 -S | FileCheck %s --check-prefixes=COUNTER1
54
; RUN: opt < %s -passes=instcombine --debug-counter=assume-queries-counter=1-2 -S | FileCheck %s --check-prefixes=COUNTER2

llvm/test/CodeGen/AArch64/GlobalISel/counter-fallback.ll

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
; RUN: llc -mtriple=aarch64-- -global-isel -global-isel-abort=0 -debug-counter=globalisel=0 %s -o - 2>/dev/null | FileCheck %s
33
; RUN: llc -mtriple=aarch64-- -global-isel -global-isel-abort=0 -debug-counter=globalisel=0 %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=DEBUG
44

5-
; REQUIRES: asserts
6-
75
; DEBUG-NOT: Falling back for function test1
86
; DEBUG: Falling back for function test2
97

llvm/test/CodeGen/AMDGPU/waitcnt-debug.mir

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# REQUIRES: asserts
21
# RUN: llc -mtriple=amdgcn -verify-machineinstrs -run-pass si-insert-waitcnts -debug-counter=si-insert-waitcnts-forcelgkm=0 -o - %s | FileCheck -check-prefixes=GCN,LGKM %s
32
# RUN: llc -mtriple=amdgcn -verify-machineinstrs -run-pass si-insert-waitcnts -debug-counter=si-insert-waitcnts-forceexp=0-1 -o - %s | FileCheck -check-prefixes=GCN,EXP %s
43
# RUN: llc -mtriple=amdgcn -verify-machineinstrs -run-pass si-insert-waitcnts -debug-counter=si-insert-waitcnts-forcevm=0-2 -o - %s | FileCheck -check-prefixes=GCN,VM %s

llvm/test/CodeGen/NVPTX/param-add.ll

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22
; RUN: llc < %s -march=nvptx64 --debug-counter=dagcombine=0 | FileCheck %s
33
; RUN: %if ptxas %{ llc < %s -march=nvptx64 --debug-counter=dagcombine=0 | %ptxas-verify %}
44

5-
; REQUIRES: asserts
6-
; asserts are required for --debug-counter=dagcombine=0 to have the intended
7-
; effect of disabling DAG combines, which exposes the bug. When combines are
8-
; enabled the bug does not occur.
9-
105
%struct.1float = type <{ [1 x float] }>
116

127
declare i32 @callee(%struct.1float %a)

llvm/test/CodeGen/PowerPC/peephole-counter-XToI.mir

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 4
2-
# REQUIRES: asserts
32
# RUN: llc -mtriple=powerpc64le-unknown-linux-gnu -verify-machineinstrs \
43
# RUN: -run-pass ppc-mi-peepholes %s -o - | FileCheck %s --check-prefix=ALL
54
# RUN: llc -mtriple=powerpc64le-unknown-linux-gnu -verify-machineinstrs \

llvm/test/CodeGen/X86/dag-combine-counter.ll

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
22
; RUN: llc -mtriple=x86_64-- -debug-counter=dagcombine=0-5 < %s | FileCheck %s
33

4-
; REQUIRES: asserts
5-
64
define i32 @test(i32 %x) {
75
; CHECK-LABEL: test:
86
; CHECK: # %bb.0:

llvm/test/CodeGen/X86/pr114360.ll

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2-
; REQUIRES: asserts
32
; RUN: llc < %s -mtriple=x86_64-- -debug-counter=dagcombine=0 | FileCheck %s
43

54
; BUG: shrinkAndImmediate folds away the AND after the ZEXT has already been folded away to SUBREG_TO_REG losing implicit zext.

llvm/test/Other/X86/debugcounter-divrempairs.ll

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
; REQUIRES: asserts
21
; RUN: opt < %s -passes=div-rem-pairs -debug-counter=div-rem-pairs-transform=1 \
32
; RUN: -S -mtriple=x86_64-unknown-unknown | FileCheck %s
43
;; Test that, with debug counters on, we only skip the first div-rem-pairs opportunity, optimize one after it,

0 commit comments

Comments
 (0)