[clang] [compiler-rt] [llvm] [TSan] Add escape analysis for redundant instrumentation elimination (PR #169896)

Alexey Paznikov via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 31 23:22:25 PDT 2026


================

----------------
apaznikov wrote:

Thank you for the suggestion. We looked at StackSafetyAnalysis.

The two analyses answer different questions and rely on different mechanisms:
* **StackSafetyAnalysis** proves spatial safety — all accesses to an alloca stay in-bounds.
* **EscapeAnalysis** proves thread locality — a pointer to an allocation cannot be observed by another thread.

These properties are orthogonal: an object can be stack-safe yet have its address stored into a global (causing a race), or be thread-local yet have out-of-bounds accesses. Merging the two would complicate both, since they have no shared algorithmic core. 

Two additional practical differences: EscapeAnalysis handles heap allocations in addition to stack ones, and it works intraprocedurally without requiring ModuleSummaryIndex or ThinLTO. That said, in the future EscapeAnalysis could potentially reuse StackSafetyAnalysis's interprocedural summary infrastructure to extend its reach across call boundaries

https://github.com/llvm/llvm-project/pull/169896


More information about the cfe-commits mailing list