[all-commits] [llvm/llvm-project] 042a38: [Support] Optimize DebugCounter (#170305)

Nikita Popov via All-commits all-commits at lists.llvm.org
Tue Dec 2 22:55:27 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 042a38f0bfe5c9f49df5d4cb5e23092e512c9fbe
      https://github.com/llvm/llvm-project/commit/042a38f0bfe5c9f49df5d4cb5e23092e512c9fbe
  Author: Nikita Popov <npopov at redhat.com>
  Date:   2025-12-03 (Wed, 03 Dec 2025)

  Changed paths:
    M llvm/include/llvm/Support/DebugCounter.h
    M llvm/lib/Support/DebugCounter.cpp
    M llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

  Log Message:
  -----------
  [Support] Optimize DebugCounter (#170305)

Currently, DebugCounters work by creating a unique counter ID during
registration, and then using that ID to look up the counter information
in the global registry.

However, this means that anything working with counters has to always go
through the global instance. This includes the fast path that checks
whether any counters are enabled.

Instead, we can drop the counter IDs, and make the counter variables use
CounterInfo themselves. We can then directly check whether the specific
counter is active without going through the global registry. This is
both faster for the fast-path where all counters are disabled, and also
faster for the case where only one counter is active (as the fast-path
can now still be used for all the disabled counters).

After this change, disabled counters become essentially free at runtime,
and we should be able to enable them in non-assert builds as well.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list