[llvm-branch-commits] [asan] Optimize initialization order checking (PR #101837)

Vitaly Buka via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sat Aug 3 10:35:29 PDT 2024


https://github.com/vitalybuka created https://github.com/llvm/llvm-project/pull/101837

Before the patch each TU was executing pair
`__asan_before_dynamic_init` and
`__asan_after_dynamic_init`.

`__asan_before_dynamic_init` supports incremental
poisoning, but `__asan_after_dynamic_init`
unpoisons all globals, so
`__asan_before_dynamic_init` must repoison
everything again.

So it's O(N^2) where N is the number of globals
(or TUs). It can be expensive for large binaries.

The patch will make it O(N).

The patch requires LLD and platform with
SANITIZER_CAN_USE_PREINIT_ARRAY. For the rest it
continue to be O(N^2).





More information about the llvm-branch-commits mailing list