[BasicAA] Handle PHIs without incoming values gracefully
authorDaniil Suchkov <dsuchkov@azul.com>
Fri, 4 Jun 2021 23:17:02 +0000 (23:17 +0000)
committerDaniil Suchkov <dsuchkov@azul.com>
Mon, 7 Jun 2021 21:39:01 +0000 (21:39 +0000)
Fix a bug introduced by f6f6f6375d1a4bced8a6e79a78726ab32b8dd879.
Now for empty PHIs, instead of crashing on assert(hasVal()) in
Optional's internals, we'll return NoAlias, as we did before that patch.

Differential Revision: https://reviews.llvm.org/D103831

llvm/lib/Analysis/BasicAliasAnalysis.cpp
llvm/test/Transforms/JumpThreading/aa-crash-phi-no-args.ll

index dec7fcb..356259f 100644 (file)
@@ -1293,6 +1293,8 @@ BasicAAResult::aliasSelect(const SelectInst *SI, LocationSize SISize,
 AliasResult BasicAAResult::aliasPHI(const PHINode *PN, LocationSize PNSize,
                                     const Value *V2, LocationSize V2Size,
                                     AAQueryInfo &AAQI) {
+  if (!PN->getNumIncomingValues())
+    return AliasResult::NoAlias;
   // If the values are PHIs in the same block, we can do a more precise
   // as well as efficient check: just check for aliases between the values
   // on corresponding edges.
index 10de852..5bcd001 100644 (file)
@@ -1,4 +1,3 @@
-; XFAIL: *
 ; REQUIRES: asserts
 ; RUN: opt -jump-threading -aa-pipeline basic-aa -S -disable-output %s
 ; RUN: opt -passes=jump-threading -aa-pipeline basic-aa -S -disable-output %s