diff --git a/llvm/include/llvm/Instructions.h b/llvm/include/llvm/Instructions.h index f520310529bd..3e250d85274f 100644 --- a/llvm/include/llvm/Instructions.h +++ b/llvm/include/llvm/Instructions.h @@ -1806,16 +1806,16 @@ private: return User::operator new(s, 0); } void growOperands(); - void init(Value *PersFn, unsigned NumReservedValues, const Twine &NameStr); + void init(Function *PersFn, unsigned NumReservedValues, const Twine &NameStr); - explicit LandingPadInst(Type *RetTy, Value *PersonalityFn, + explicit LandingPadInst(Type *RetTy, Function *PersonalityFn, unsigned NumReservedValues, const Twine &NameStr, Instruction *InsertBefore) : Instruction(RetTy, Instruction::LandingPad, 0, 0, InsertBefore), IsCleanup(false) { init(PersonalityFn, 1 + NumReservedValues, NameStr); } - explicit LandingPadInst(Type *RetTy, Value *PersonalityFn, + explicit LandingPadInst(Type *RetTy, Function *PersonalityFn, unsigned NumReservedValues, const Twine &NameStr, BasicBlock *InsertAtEnd) : Instruction(RetTy, Instruction::LandingPad, 0, 0, InsertAtEnd), @@ -1825,14 +1825,14 @@ private: protected: virtual LandingPadInst *clone_impl() const; public: - static LandingPadInst *Create(Type *RetTy, Value *PersonalityFn, + static LandingPadInst *Create(Type *RetTy, Function *PersonalityFn, unsigned NumReservedValues, const Twine &NameStr = "", Instruction *InsertBefore = 0) { return new LandingPadInst(RetTy, PersonalityFn, NumReservedValues, NameStr, InsertBefore); } - static LandingPadInst *Create(Type *RetTy, Value *PersonalityFn, + static LandingPadInst *Create(Type *RetTy, Function *PersonalityFn, unsigned NumReservedValues, const Twine &NameStr, BasicBlock *InsertAtEnd) { return new LandingPadInst(RetTy, PersonalityFn, NumReservedValues, NameStr, @@ -1845,7 +1845,9 @@ public: /// getPersonalityFn - Get the personality function associated with this /// landing pad. - const Value *getPersonalityFn() const { return getOperand(0); } + const Function *getPersonalityFn() const { + return cast(getOperand(0)); + } // Simple accessors. bool isCleanup() const { return IsCleanup; } diff --git a/llvm/include/llvm/Support/IRBuilder.h b/llvm/include/llvm/Support/IRBuilder.h index 7f89b247c486..542ee10cde36 100644 --- a/llvm/include/llvm/Support/IRBuilder.h +++ b/llvm/include/llvm/Support/IRBuilder.h @@ -1198,7 +1198,7 @@ public: return Insert(InsertValueInst::Create(Agg, Val, Idxs), Name); } - Value *CreateLandingPad(Type *Ty, Value *PersFn, unsigned NumClauses, + Value *CreateLandingPad(Type *Ty, Function *PersFn, unsigned NumClauses, const Twine &Name = "") { return Insert(LandingPadInst::Create(Ty, PersFn, NumClauses, Name)); } diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index b3f4d476a24d..fe4bb2e6376f 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -3547,7 +3547,8 @@ bool LLParser::ParseLandingPad(Instruction *&Inst, PerFunctionState &PFS) { } while (EatIfPresent(lltok::comma)); } - LandingPadInst *LP = LandingPadInst::Create(Ty, PersFn, Clauses.size()); + LandingPadInst *LP = LandingPadInst::Create(Ty, cast(PersFn), + Clauses.size()); LP->setCleanup(IsCleanup); for (SmallVectorImpl(PersFn), + NumClauses); LP->setCleanup(IsCleanup); for (unsigned J = 0; J != NumClauses; ++J) { LandingPadInst::ClauseType CT = diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 67707c6425e3..c5c979045681 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -914,10 +914,6 @@ void SelectionDAGBuilder::visitPHI(const PHINode &) { llvm_unreachable("SelectionDAGBuilder shouldn't visit PHI nodes!"); } -void SelectionDAGBuilder::visitLandingPad(const LandingPadInst &) { - // FIXME: Handle this -} - void SelectionDAGBuilder::visit(unsigned Opcode, const User &I) { // Note: this doesn't use InstVisitor, because it has to work with // ConstantExpr's in addition to instructions. @@ -1813,7 +1809,13 @@ void SelectionDAGBuilder::visitUnwind(const UnwindInst &I) { } void SelectionDAGBuilder::visitResume(const ResumeInst &RI) { + llvm_unreachable("SelectionDAGBuilder shouldn't visit resume instructions!"); +} + +void SelectionDAGBuilder::visitLandingPad(const LandingPadInst &) { // FIXME: Handle this + assert(FuncInfo.MBB->isLandingPad() && + "Call to landingpad not in landing pad!"); } /// handleSmallSwitchCaseRange - Emit a series of specific tests (suitable for diff --git a/llvm/lib/VMCore/Core.cpp b/llvm/lib/VMCore/Core.cpp index 5e93c73a344d..318805b9159a 100644 --- a/llvm/lib/VMCore/Core.cpp +++ b/llvm/lib/VMCore/Core.cpp @@ -1686,7 +1686,8 @@ LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef B, LLVMValueRef Fn, LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef PersFn, unsigned NumClauses, const char *Name) { - return wrap(unwrap(B)->CreateLandingPad(unwrap(Ty), unwrap(PersFn), + return wrap(unwrap(B)->CreateLandingPad(unwrap(Ty), + cast(unwrap(PersFn)), NumClauses, Name)); } diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp index c980a7189a3a..9fdff0773a64 100644 --- a/llvm/lib/VMCore/Instructions.cpp +++ b/llvm/lib/VMCore/Instructions.cpp @@ -170,12 +170,12 @@ Value *PHINode::hasConstantValue() const { // LandingPadInst Implementation //===----------------------------------------------------------------------===// -void LandingPadInst::init(Value *PersFn, unsigned NumReservedValues, +void LandingPadInst::init(Function *PersFn, unsigned NumReservedValues, const Twine &NameStr) { ReservedSpace = NumReservedValues; NumOperands = 1; OperandList = allocHungoffUses(ReservedSpace); - OperandList[0] = PersFn; + OperandList[0] = (Value*)PersFn; setName(NameStr); }