[llvm] [ASan] Don't mark alloca as safe if address escapes to callee (PR #178591)
Florian Mayer via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 4 10:06:57 PST 2026
================
@@ -920,7 +920,11 @@ const StackSafetyGlobalInfo::InfoTy &StackSafetyGlobalInfo::getInfo() const {
++NumAllocaTotal;
const AllocaInst *AI = KV.first;
auto AIRange = getStaticAllocaSizeRange(*AI);
- if (AIRange.contains(KV.second.Range)) {
+ // An alloca is safe if all accesses are in-bounds AND the address
+ // doesn't escape to other functions. If the address is passed to
+ // another function, ASan may instrument accesses in the callee, which
+ // requires the caller to properly initialize shadow memory.
+ if (AIRange.contains(KV.second.Range) && KV.second.Calls.empty()) {
----------------
fmayer wrote:
I think this unnecessarily degrades Stack Safety for HWASan, which doesn't have this problem.
https://github.com/llvm/llvm-project/pull/178591
More information about the llvm-commits
mailing list