[PATCH] D96996: [BasicAA] Add simple depth limit to avoid stack overflow (PR49151)
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 18 14:20:29 PST 2021
nikic created this revision.
nikic added reviewers: asbirlea, jdoerfert.
Herald added a subscriber: hiraditya.
nikic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This is a simpler variant on D96647 <https://reviews.llvm.org/D96647>. It just adds a straightforward depth limit with a high cutoff, without introducing complex logic for BatchAA consistency. It accepts that we may cache a sub-optimal result if the depth limit is hit.
Eventually this should be more fully addressed by D96647 <https://reviews.llvm.org/D96647> or similar, but in the meantime this avoids stack overflows in a cheap way.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D96996
Files:
llvm/lib/Analysis/BasicAliasAnalysis.cpp
Index: llvm/lib/Analysis/BasicAliasAnalysis.cpp
===================================================================
--- llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -1559,6 +1559,13 @@
V2Size = LocationSize::afterPointer();
}
+ // FIXME: If this depth limit is hit, then we may cache sub-optimal results
+ // for recursive queries. For this reason, this limit is chosen to be large
+ // enough to be very rarely hit, while still being small enough to avoid
+ // stack overflows.
+ if (AAQI.Depth >= 512)
+ return MayAlias;
+
// Check the cache before climbing up use-def chains. This also terminates
// otherwise infinitely recursive queries.
AAQueryInfo::LocPair Locs(MemoryLocation(V1, V1Size, V1AAInfo),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96996.324772.patch
Type: text/x-patch
Size: 778 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210218/5aff2201/attachment.bin>
More information about the llvm-commits
mailing list