[PATCH] D45910: [BasicAA] Don't assume a PHI node has inputs

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 20 16:46:23 PDT 2018


craig.topper created this revision.
craig.topper added reviewers: dberlin, sanjoy.

aliasPHI assumes that a phi node must have at least one input. Our internal code base with some jumpthreading changes was able to get into this code with a phi with no inputs in some unreachable code.

It seems robust to not have this assumption.

I don't have a test case that works on trunk.


https://reviews.llvm.org/D45910

Files:
  lib/Analysis/BasicAliasAnalysis.cpp


Index: lib/Analysis/BasicAliasAnalysis.cpp
===================================================================
--- lib/Analysis/BasicAliasAnalysis.cpp
+++ lib/Analysis/BasicAliasAnalysis.cpp
@@ -1536,6 +1536,10 @@
       V1Srcs.push_back(PV1);
   }
 
+  // It's possible for a phi in unreachable code to have no inputs.
+  if (V1Srcs.empty())
+    return MayAlias;
+
   // If this PHI node is recursive, set the size of the accessed memory to
   // unknown to represent all the possible values the GEP could advance the
   // pointer to.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45910.143411.patch
Type: text/x-patch
Size: 538 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180420/97859c1e/attachment.bin>


More information about the llvm-commits mailing list