[all-commits] [llvm/llvm-project] ad3c1e: [clang][Analysis] Speed up LiveVariables set merge...

Gábor Horváth via All-commits all-commits at lists.llvm.org
Tue Jul 14 04:29:05 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ad3c1ef174f9cac5bd0332747226740ce1b16159
      https://github.com/llvm/llvm-project/commit/ad3c1ef174f9cac5bd0332747226740ce1b16159
  Author: Gábor Horváth <xazax.hun at gmail.com>
  Date:   2026-07-14 (Tue, 14 Jul 2026)

  Changed paths:
    M clang/lib/Analysis/LiveVariables.cpp

  Log Message:
  -----------
  [clang][Analysis] Speed up LiveVariables set merge (#209430)

LiveVariables' mergeSets built the union by unconditionally inserting
every element of B into A. Apply the two cheap tricks the
lifetime-safety analysis uses in its dataflow join:

* Return early when both operands are the same tree (an O(1) pointer
comparison), skipping the merge entirely. Merged liveness values are
canonicalized, so two predecessors with identical liveness share the
same tree -- common at confluence points.
* Insert the smaller set into the larger one, so the number of O(log n)
insertions is min(|A|, |B|) rather than always |B|.

The result is unchanged: set union is commutative and order-independent.

On a pathological function (1000 simultaneously-live locals across 5000
control-flow merges of identical sets) the liveness computation is ~18%
faster, essentially all from the identical-set short circuit. On real
translation units the merge is a small fraction of the analysis, so the
effect is within noise (measured neutral on DAGCombiner.cpp and
X86ISelLowering.cpp); this mainly avoids redundant work at unchanged
confluence points and brings the two dataflow analyses' merges into
line.

Assisted by: Claude Opus 4.8

Co-authored-by: Gabor Horvath <gaborh at apple.com>



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