From b976e668165e1875a8f1eb7af800e33bb1e4393d Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 16 Oct 2004 18:08:06 +0000 Subject: [PATCH] Add support for undef and unreachable git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17041 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Linker/LinkModules.cpp | 2 +- lib/VMCore/AsmWriter.cpp | 3 +++ lib/VMCore/Instruction.cpp | 1 + lib/VMCore/Instructions.cpp | 9 +++++++++ lib/VMCore/Linker.cpp | 2 +- 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index 70bd22cd444..fbf09781bae 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -310,7 +310,7 @@ static Value *RemapOperand(const Value *In, Operands[i] = cast(RemapOperand(CPS->getOperand(i), LocalMap, GlobalMap)); Result = ConstantStruct::get(cast(CPS->getType()), Operands); - } else if (isa(CPV)) { + } else if (isa(CPV) || isa(CPV)) { Result = const_cast(CPV); } else if (isa(CPV)) { Result = cast(RemapOperand(CPV, LocalMap, GlobalMap)); diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index 236e243caad..2e973feb161 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -518,6 +518,9 @@ static void WriteConstantInt(std::ostream &Out, const Constant *CV, } else if (isa(CV)) { Out << "null"; + } else if (isa(CV)) { + Out << "undef"; + } else if (const ConstantExpr *CE = dyn_cast(CV)) { Out << CE->getOpcodeName() << " ("; diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp index 4ea5775330a..17970ac9ba9 100644 --- a/lib/VMCore/Instruction.cpp +++ b/lib/VMCore/Instruction.cpp @@ -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"; diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index 38e9255a9b3..029ee6a0f6b 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -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();} diff --git a/lib/VMCore/Linker.cpp b/lib/VMCore/Linker.cpp index 70bd22cd444..fbf09781bae 100644 --- a/lib/VMCore/Linker.cpp +++ b/lib/VMCore/Linker.cpp @@ -310,7 +310,7 @@ static Value *RemapOperand(const Value *In, Operands[i] = cast(RemapOperand(CPS->getOperand(i), LocalMap, GlobalMap)); Result = ConstantStruct::get(cast(CPS->getType()), Operands); - } else if (isa(CPV)) { + } else if (isa(CPV) || isa(CPV)) { Result = const_cast(CPV); } else if (isa(CPV)) { Result = cast(RemapOperand(CPV, LocalMap, GlobalMap)); -- 2.34.1