Keep iterating over all uses when meeting a phi node in AllUsesOfValueWillTrapIfNull().
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Fri, 29 Jan 2010 23:54:14 +0000 (23:54 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Fri, 29 Jan 2010 23:54:14 +0000 (23:54 +0000)
This bug was exposed by my inliner cost changes in r94615, and caused failures
of lencod on most architectures when building with LTO.

This patch fixes lencod and 464.h264ref on x86-64 (and likely others).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94858 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/IPO/GlobalOpt.cpp

index ee260e9488e98b31f92c330f837a62ec74bb7141..ac91631f56c48a570f73eb0e5ccf1f17a8de6f4d 100644 (file)
@@ -638,8 +638,8 @@ static bool AllUsesOfValueWillTrapIfNull(Value *V,
     } else if (PHINode *PN = dyn_cast<PHINode>(*UI)) {
       // If we've already seen this phi node, ignore it, it has already been
       // checked.
-      if (PHIs.insert(PN))
-        return AllUsesOfValueWillTrapIfNull(PN, PHIs);
+      if (PHIs.insert(PN) && !AllUsesOfValueWillTrapIfNull(PN, PHIs))
+        return false;
     } else if (isa<ICmpInst>(*UI) &&
                isa<ConstantPointerNull>(UI->getOperand(1))) {
       // Ignore setcc X, null