OSDN Git Service

second half of fix for PR4366: don't zap store to null of
authorChris Lattner <sabre@nondot.org>
Fri, 12 Jun 2009 21:01:07 +0000 (21:01 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 12 Jun 2009 21:01:07 +0000 (21:01 +0000)
non-default addrspaces.

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

lib/Transforms/Scalar/SimplifyCFGPass.cpp

index b499279..5a85a04 100644 (file)
@@ -125,13 +125,17 @@ static bool MarkAliveBlocks(BasicBlock *BB,
         }
       }
       
-      if (StoreInst *SI = dyn_cast<StoreInst>(BBI))
-        if (isa<ConstantPointerNull>(SI->getOperand(1)) ||
-            isa<UndefValue>(SI->getOperand(1))) {
+      if (StoreInst *SI = dyn_cast<StoreInst>(BBI)) {
+        Value *Ptr = SI->getOperand(1);
+        
+        if (isa<UndefValue>(Ptr) ||
+            (isa<ConstantPointerNull>(Ptr) &&
+             cast<PointerType>(Ptr->getType())->getAddressSpace() == 0)) {
           ChangeToUnreachable(SI);
           Changed = true;
           break;
         }
+      }
     }
 
     // Turn invokes that call 'nounwind' functions into ordinary calls.