[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
Fri Feb 19 02:53:50 PST 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG1d9f4903c615: [BasicAA] Add simple depth limit to avoid stack overflow (PR49151) (authored by nikic).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96996/new/

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.324932.patch
Type: text/x-patch
Size: 778 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210219/2f67e81a/attachment.bin>


More information about the llvm-commits mailing list