Add support for undef and unreachable

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17041 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2004-10-16 18:08:06 +00:00
parent b9f18592a6
commit b976e66816
5 changed files with 15 additions and 2 deletions

View 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));

View 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() << " (";

View 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";

View 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();}

View 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));