Handle undef values as undefined on the constant lattice
authorChris Lattner <sabre@nondot.org>
Sat, 16 Oct 2004 18:09:41 +0000 (18:09 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 16 Oct 2004 18:09:41 +0000 (18:09 +0000)
ignore unreachable instructions

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

lib/Transforms/Scalar/SCCP.cpp

index 7921a235d26360b8360f77cd657f6f6f0811caf9..aa57159b6e35148f08c60ef8f5651a641bc96a20 100644 (file)
@@ -174,9 +174,11 @@ private:
   inline InstVal &getValueState(Value *V) {
     hash_map<Value*, InstVal>::iterator I = ValueState.find(V);
     if (I != ValueState.end()) return I->second;  // Common case, in the map
-      
-    if (Constant *CPV = dyn_cast<Constant>(V)) {  // Constants are constant
-      ValueState[CPV].markConstant(CPV);
+
+    if (isa<UndefValue>(V)) {
+      // Nothing to do, remain undefined.
+    } else if (Constant *CPV = dyn_cast<Constant>(V)) {
+      ValueState[CPV].markConstant(CPV);          // Constants are constant
     } else if (isa<Argument>(V)) {                // Arguments are overdefined
       ValueState[V].markOverdefined();
     }
@@ -236,6 +238,7 @@ private:
     visitTerminatorInst(I);
   }
   void visitUnwindInst    (TerminatorInst &I) { /*returns void*/ }
+  void visitUnreachableInst(TerminatorInst &I) { /*returns void*/ }
   void visitAllocationInst(Instruction &I) { markOverdefined(&I); }
   void visitVANextInst    (Instruction &I) { markOverdefined(&I); }
   void visitVAArgInst     (Instruction &I) { markOverdefined(&I); }