Add support for undef and unreachable
authorChris Lattner <sabre@nondot.org>
Sat, 16 Oct 2004 18:08:06 +0000 (18:08 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 16 Oct 2004 18:08:06 +0000 (18:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17041 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Linker/LinkModules.cpp
lib/VMCore/AsmWriter.cpp
lib/VMCore/Instruction.cpp
lib/VMCore/Instructions.cpp
lib/VMCore/Linker.cpp

index 70bd22cd4447f3d9f6ba262e0b5096c92c304482..fbf09781baed31825e3ee855c12ae0dce76a2c40 100644 (file)
@@ -310,7 +310,7 @@ static Value *RemapOperand(const Value *In,
         Operands[i] =
           cast<Constant>(RemapOperand(CPS->getOperand(i), LocalMap, GlobalMap));
       Result = ConstantStruct::get(cast<StructType>(CPS->getType()), Operands);
-    } else if (isa<ConstantPointerNull>(CPV)) {
+    } else if (isa<ConstantPointerNull>(CPV) || isa<UndefValue>(CPV)) {
       Result = const_cast<Constant*>(CPV);
     } else if (isa<GlobalValue>(CPV)) {
       Result = cast<Constant>(RemapOperand(CPV, LocalMap, GlobalMap));
index 236e243caad1c04483dd0cd293af65dca1df8373..2e973feb161d4f816f00f991ae9302d9af6dd624 100644 (file)
@@ -518,6 +518,9 @@ static void WriteConstantInt(std::ostream &Out, const Constant *CV,
   } else if (isa<ConstantPointerNull>(CV)) {
     Out << "null";
 
+  } else if (isa<UndefValue>(CV)) {
+    Out << "undef";
+
   } else if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CV)) {
     Out << CE->getOpcodeName() << " (";
     
index 4ea5775330a1b1d1930c4ce0ce75875c7df2bcc5..17970ac9ba9ad84ea22d6542ed6be3e907195c56 100644 (file)
@@ -88,6 +88,7 @@ const char *Instruction::getOpcodeName(unsigned OpCode) {
   case Switch: return "switch";
   case Invoke: return "invoke";
   case Unwind: return "unwind";
+  case Unreachable: return "unreachable";
     
   // Standard binary operators...
   case Add: return "add";
index 38e9255a9b3430f6eeb95827c1666e6e46fa345e..029ee6a0f6b5c83de203207fbb45ea42861d7c9e 100644 (file)
@@ -248,6 +248,14 @@ void UnwindInst::setSuccessor(unsigned idx, BasicBlock *NewSucc) {
   assert(0 && "UnwindInst has no successors!");
 }
 
+//===----------------------------------------------------------------------===//
+//                      UnreachableInst Implementation
+//===----------------------------------------------------------------------===//
+
+void UnreachableInst::setSuccessor(unsigned idx, BasicBlock *NewSucc) {
+  assert(0 && "UnreachableInst has no successors!");
+}
+
 //===----------------------------------------------------------------------===//
 //                        BranchInst Implementation
 //===----------------------------------------------------------------------===//
@@ -832,3 +840,4 @@ BranchInst *BranchInst::clone() const { return new BranchInst(*this); }
 SwitchInst *SwitchInst::clone() const { return new SwitchInst(*this); }
 InvokeInst *InvokeInst::clone() const { return new InvokeInst(*this); }
 UnwindInst *UnwindInst::clone() const { return new UnwindInst(); }
+UnreachableInst *UnreachableInst::clone() const { return new UnreachableInst();}
index 70bd22cd4447f3d9f6ba262e0b5096c92c304482..fbf09781baed31825e3ee855c12ae0dce76a2c40 100644 (file)
@@ -310,7 +310,7 @@ static Value *RemapOperand(const Value *In,
         Operands[i] =
           cast<Constant>(RemapOperand(CPS->getOperand(i), LocalMap, GlobalMap));
       Result = ConstantStruct::get(cast<StructType>(CPS->getType()), Operands);
-    } else if (isa<ConstantPointerNull>(CPV)) {
+    } else if (isa<ConstantPointerNull>(CPV) || isa<UndefValue>(CPV)) {
       Result = const_cast<Constant*>(CPV);
     } else if (isa<GlobalValue>(CPV)) {
       Result = cast<Constant>(RemapOperand(CPV, LocalMap, GlobalMap));