llvm-project
eef4c8bc - [analyzer][NFC] Cache the AST-only part of the loop unrolling decision (#246977)

Commit
2 days ago
[analyzer][NFC] Cache the AST-only part of the loop unrolling decision (#246977) - With `unroll-loops=true`, `updateLoopStack()` runs `shouldCompletelyUnroll()` every time a path enters a loop. - Its first half is a pure function of the loop's AST: it rebuilds the large `forLoopMatcher()` tree, matches it, and evaluates the bound. - Memoize that half per loop in a `LoopUnrollingCache` owned by `ExprEngine`. - The path-dependent `isPossiblyEscaped()` still runs on every entry, but now builds its matcher once per call instead of once per visited statement. - `unroll-loops` is off by default, so only users enabling it benefit. Analysis-time impact (instructions retired in millions, `unroll-loops=true`; inputs are the reproducers from llvm/llvm-project#105512; ON = default graph trimming, OFF = `graph-trim-interval=0`): file mode before after change ruby-unicode.c ON 22710 21334 -6.1% ruby-unicode.c OFF 24059 22545 -6.3% linux-topro.c ON 61158 60514 -1.1% linux-topro.c OFF 61628 61185 -0.7% clang-MSP430ISelDAGToDAG.cpp ON 26295 26356 +0.2% (noise) clang-MSP430ISelDAGToDAG.cpp OFF 26809 26697 -0.4% (noise) 20 clang/lib TUs analyzed with their own compile flags and the same config (instructions retired in billions; user CPU seconds): - Diagnostics are byte-identical on all inputs. Assisted-by: Claude
Author
Parents
Loading