llvm.org GIT mirror llvm / dccc03b
Add the 'resume' instruction for the new EH rewrite. This adds the 'resume' instruction class, IR parsing, and bitcode reading and writing. The 'resume' instruction resumes propagation of an existing (in-flight) exception whose unwinding was interrupted with a 'landingpad' instruction (to be added later). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136589 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 9 years ago
24 changed file(s) with 258 addition(s) and 74 deletion(s). Raw diff Collapse all Expand all
123123
  • 'indirectbr' Instruction
  • 124124
  • 'invoke' Instruction
  • 125125
  • 'unwind' Instruction
  • 126
  • 'resume' Instruction
  • 126127
  • 'unreachable' Instruction
  • 127128
    128129
    30223023 control flow, not values (the one exception being the
    30233024 'invoke' instruction).

    30243025
    3025

    There are seven different terminator instructions: the

    3026

    There are eight different terminator instructions: the

    30263027 'ret' instruction, the
    30273028 'br' instruction, the
    30283029 'switch' instruction, the
    30293030 ''indirectbr' Instruction, the
    30303031 'invoke' instruction, the
    3031 'unwind' instruction, and the
    3032 'unwind' instruction, the
    3033 'resume' instruction, and the
    30323034 'unreachable' instruction.

    30333035
    30343036
    33463348
    33473349

    Note that the code generator does not yet completely support unwind, and

    33483350 that the invoke/unwind semantics are likely to change in future versions.

    3351
    3352
    3353
    3354
    3355
    3356

    3357 'resume' Instruction
    3358
    3359
    3360
    3361
    3362
    Syntax:
    3363
    
                      
                    
    3364 resume <type> <value>
    3365
    3366
    3367
    Overview:
    3368

    The 'resume' instruction is a terminator instruction that has no

    3369 successors.

    3370
    3371
    Arguments:
    3372

    The 'resume' instruction's argument must have the same type as the

    3373 result of any 'landingpad' instruction in the same function.

    3374
    3375
    Semantics:
    3376

    The 'resume' instruction resumes propagation of an existing

    3377 (in-flight) exception whose unwinding was interrupted with
    3378 a landingpad instruction.

    3379
    3380
    Example:
    3381
    
                      
                    
    3382 resume { i8*, i32 } %exn
    3383
    33493384
    33503385
    33513386
    303303 FUNC_CODE_INST_FENCE = 36, // FENCE: [ordering, synchscope]
    304304 FUNC_CODE_INST_CMPXCHG = 37, // CMPXCHG: [ptrty,ptr,cmp,new, align, vol,
    305305 // ordering, synchscope]
    306 FUNC_CODE_INST_ATOMICRMW = 38 // ATOMICRMW: [ptrty,ptr,val, operation,
    306 FUNC_CODE_INST_ATOMICRMW = 38, // ATOMICRMW: [ptrty,ptr,val, operation,
    307307 // align, vol,
    308308 // ordering, synchscope]
    309 FUNC_CODE_INST_RESUME = 39 // RESUME: [opval]
    309310 };
    310311 } // End bitc namespace
    311312 } // End llvm namespace
    9999 HANDLE_TERM_INST ( 4, IndirectBr , IndirectBrInst)
    100100 HANDLE_TERM_INST ( 5, Invoke , InvokeInst)
    101101 HANDLE_TERM_INST ( 6, Unwind , UnwindInst)
    102 HANDLE_TERM_INST ( 7, Unreachable, UnreachableInst)
    103 LAST_TERM_INST ( 7)
    102 HANDLE_TERM_INST ( 7, Resume , ResumeInst)
    103 HANDLE_TERM_INST ( 8, Unreachable, UnreachableInst)
    104 LAST_TERM_INST ( 8)
    104105
    105106 // Standard binary operators...
    106 FIRST_BINARY_INST( 8)
    107 HANDLE_BINARY_INST( 8, Add , BinaryOperator)
    108 HANDLE_BINARY_INST( 9, FAdd , BinaryOperator)
    109 HANDLE_BINARY_INST(10, Sub , BinaryOperator)
    110 HANDLE_BINARY_INST(11, FSub , BinaryOperator)
    111 HANDLE_BINARY_INST(12, Mul , BinaryOperator)
    112 HANDLE_BINARY_INST(13, FMul , BinaryOperator)
    113 HANDLE_BINARY_INST(14, UDiv , BinaryOperator)
    114 HANDLE_BINARY_INST(15, SDiv , BinaryOperator)
    115 HANDLE_BINARY_INST(16, FDiv , BinaryOperator)
    116 HANDLE_BINARY_INST(17, URem , BinaryOperator)
    117 HANDLE_BINARY_INST(18, SRem , BinaryOperator)
    118 HANDLE_BINARY_INST(19, FRem , BinaryOperator)
    107 FIRST_BINARY_INST( 9)
    108 HANDLE_BINARY_INST( 9, Add , BinaryOperator)
    109 HANDLE_BINARY_INST(10, FAdd , BinaryOperator)
    110 HANDLE_BINARY_INST(11, Sub , BinaryOperator)
    111 HANDLE_BINARY_INST(12, FSub , BinaryOperator)
    112 HANDLE_BINARY_INST(13, Mul , BinaryOperator)
    113 HANDLE_BINARY_INST(14, FMul , BinaryOperator)
    114 HANDLE_BINARY_INST(15, UDiv , BinaryOperator)
    115 HANDLE_BINARY_INST(16, SDiv , BinaryOperator)
    116 HANDLE_BINARY_INST(17, FDiv , BinaryOperator)
    117 HANDLE_BINARY_INST(18, URem , BinaryOperator)
    118 HANDLE_BINARY_INST(19, SRem , BinaryOperator)
    119 HANDLE_BINARY_INST(20, FRem , BinaryOperator)
    119120
    120121 // Logical operators (integer operands)
    121 HANDLE_BINARY_INST(20, Shl , BinaryOperator) // Shift left (logical)
    122 HANDLE_BINARY_INST(21, LShr , BinaryOperator) // Shift right (logical)
    123 HANDLE_BINARY_INST(22, AShr , BinaryOperator) // Shift right (arithmetic)
    124 HANDLE_BINARY_INST(23, And , BinaryOperator)
    125 HANDLE_BINARY_INST(24, Or , BinaryOperator)
    126 HANDLE_BINARY_INST(25, Xor , BinaryOperator)
    127 LAST_BINARY_INST(25)
    122 HANDLE_BINARY_INST(21, Shl , BinaryOperator) // Shift left (logical)
    123 HANDLE_BINARY_INST(22, LShr , BinaryOperator) // Shift right (logical)
    124 HANDLE_BINARY_INST(23, AShr , BinaryOperator) // Shift right (arithmetic)
    125 HANDLE_BINARY_INST(24, And , BinaryOperator)
    126 HANDLE_BINARY_INST(25, Or , BinaryOperator)
    127 HANDLE_BINARY_INST(26, Xor , BinaryOperator)
    128 LAST_BINARY_INST(26)
    128129
    129130 // Memory operators...
    130 FIRST_MEMORY_INST(26)
    131 HANDLE_MEMORY_INST(26, Alloca, AllocaInst) // Stack management
    132 HANDLE_MEMORY_INST(27, Load , LoadInst ) // Memory manipulation instrs
    133 HANDLE_MEMORY_INST(28, Store , StoreInst )
    134 HANDLE_MEMORY_INST(29, GetElementPtr, GetElementPtrInst)
    135 HANDLE_MEMORY_INST(30, Fence , FenceInst )
    136 HANDLE_MEMORY_INST(31, AtomicCmpXchg , AtomicCmpXchgInst )
    137 HANDLE_MEMORY_INST(32, AtomicRMW , AtomicRMWInst )
    138 LAST_MEMORY_INST(32)
    131 FIRST_MEMORY_INST(27)
    132 HANDLE_MEMORY_INST(27, Alloca, AllocaInst) // Stack management
    133 HANDLE_MEMORY_INST(28, Load , LoadInst ) // Memory manipulation instrs
    134 HANDLE_MEMORY_INST(29, Store , StoreInst )
    135 HANDLE_MEMORY_INST(30, GetElementPtr, GetElementPtrInst)
    136 HANDLE_MEMORY_INST(31, Fence , FenceInst )
    137 HANDLE_MEMORY_INST(32, AtomicCmpXchg , AtomicCmpXchgInst )
    138 HANDLE_MEMORY_INST(33, AtomicRMW , AtomicRMWInst )
    139 LAST_MEMORY_INST(33)
    139140
    140141 // Cast operators ...
    141142 // NOTE: The order matters here because CastInst::isEliminableCastPair
    142143 // NOTE: (see Instructions.cpp) encodes a table based on this ordering.
    143 FIRST_CAST_INST(33)
    144 HANDLE_CAST_INST(33, Trunc , TruncInst ) // Truncate integers
    145 HANDLE_CAST_INST(34, ZExt , ZExtInst ) // Zero extend integers
    146 HANDLE_CAST_INST(35, SExt , SExtInst ) // Sign extend integers
    147 HANDLE_CAST_INST(36, FPToUI , FPToUIInst ) // floating point -> UInt
    148 HANDLE_CAST_INST(37, FPToSI , FPToSIInst ) // floating point -> SInt
    149 HANDLE_CAST_INST(38, UIToFP , UIToFPInst ) // UInt -> floating point
    150 HANDLE_CAST_INST(39, SIToFP , SIToFPInst ) // SInt -> floating point
    151 HANDLE_CAST_INST(40, FPTrunc , FPTruncInst ) // Truncate floating point
    152 HANDLE_CAST_INST(41, FPExt , FPExtInst ) // Extend floating point
    153 HANDLE_CAST_INST(42, PtrToInt, PtrToIntInst) // Pointer -> Integer
    154 HANDLE_CAST_INST(43, IntToPtr, IntToPtrInst) // Integer -> Pointer
    155 HANDLE_CAST_INST(44, BitCast , BitCastInst ) // Type cast
    156 LAST_CAST_INST(44)
    144 FIRST_CAST_INST(34)
    145 HANDLE_CAST_INST(34, Trunc , TruncInst ) // Truncate integers
    146 HANDLE_CAST_INST(35, ZExt , ZExtInst ) // Zero extend integers
    147 HANDLE_CAST_INST(36, SExt , SExtInst ) // Sign extend integers
    148 HANDLE_CAST_INST(37, FPToUI , FPToUIInst ) // floating point -> UInt
    149 HANDLE_CAST_INST(38, FPToSI , FPToSIInst ) // floating point -> SInt
    150 HANDLE_CAST_INST(39, UIToFP , UIToFPInst ) // UInt -> floating point
    151 HANDLE_CAST_INST(40, SIToFP , SIToFPInst ) // SInt -> floating point
    152 HANDLE_CAST_INST(41, FPTrunc , FPTruncInst ) // Truncate floating point
    153 HANDLE_CAST_INST(42, FPExt , FPExtInst ) // Extend floating point
    154 HANDLE_CAST_INST(43, PtrToInt, PtrToIntInst) // Pointer -> Integer
    155 HANDLE_CAST_INST(44, IntToPtr, IntToPtrInst) // Integer -> Pointer
    156 HANDLE_CAST_INST(45, BitCast , BitCastInst ) // Type cast
    157 LAST_CAST_INST(45)
    157158
    158159 // Other operators...
    159 FIRST_OTHER_INST(45)
    160 HANDLE_OTHER_INST(45, ICmp , ICmpInst ) // Integer comparison instruction
    161 HANDLE_OTHER_INST(46, FCmp , FCmpInst ) // Floating point comparison instr.
    162 HANDLE_OTHER_INST(47, PHI , PHINode ) // PHI node instruction
    163 HANDLE_OTHER_INST(48, Call , CallInst ) // Call a function
    164 HANDLE_OTHER_INST(49, Select , SelectInst ) // select instruction
    165 HANDLE_OTHER_INST(50, UserOp1, Instruction) // May be used internally in a pass
    166 HANDLE_OTHER_INST(51, UserOp2, Instruction) // Internal to passes only
    167 HANDLE_OTHER_INST(52, VAArg , VAArgInst ) // vaarg instruction
    168 HANDLE_OTHER_INST(53, ExtractElement, ExtractElementInst)// extract from vector
    169 HANDLE_OTHER_INST(54, InsertElement, InsertElementInst) // insert into vector
    170 HANDLE_OTHER_INST(55, ShuffleVector, ShuffleVectorInst) // shuffle two vectors.
    171 HANDLE_OTHER_INST(56, ExtractValue, ExtractValueInst)// extract from aggregate
    172 HANDLE_OTHER_INST(57, InsertValue, InsertValueInst) // insert into aggregate
    173
    174 LAST_OTHER_INST(57)
    160 FIRST_OTHER_INST(46)
    161 HANDLE_OTHER_INST(46, ICmp , ICmpInst ) // Integer comparison instruction
    162 HANDLE_OTHER_INST(47, FCmp , FCmpInst ) // Floating point comparison instr.
    163 HANDLE_OTHER_INST(48, PHI , PHINode ) // PHI node instruction
    164 HANDLE_OTHER_INST(49, Call , CallInst ) // Call a function
    165 HANDLE_OTHER_INST(50, Select , SelectInst ) // select instruction
    166 HANDLE_OTHER_INST(51, UserOp1, Instruction) // May be used internally in a pass
    167 HANDLE_OTHER_INST(52, UserOp2, Instruction) // Internal to passes only
    168 HANDLE_OTHER_INST(53, VAArg , VAArgInst ) // vaarg instruction
    169 HANDLE_OTHER_INST(54, ExtractElement, ExtractElementInst)// extract from vector
    170 HANDLE_OTHER_INST(55, InsertElement, InsertElementInst) // insert into vector
    171 HANDLE_OTHER_INST(56, ShuffleVector, ShuffleVectorInst) // shuffle two vectors.
    172 HANDLE_OTHER_INST(57, ExtractValue, ExtractValueInst)// extract from aggregate
    173 HANDLE_OTHER_INST(58, InsertValue, InsertValueInst) // insert into aggregate
    174 LAST_OTHER_INST(58)
    175175
    176176 #undef FIRST_TERM_INST
    177177 #undef HANDLE_TERM_INST
    27152715 };
    27162716
    27172717 //===----------------------------------------------------------------------===//
    2718 // ResumeInst Class
    2719 //===----------------------------------------------------------------------===//
    2720
    2721 //===---------------------------------------------------------------------------
    2722 /// ResumeInst - Resume the propagation of an exception.
    2723 ///
    2724 class ResumeInst : public TerminatorInst {
    2725 ResumeInst(const ResumeInst &RI);
    2726
    2727 explicit ResumeInst(Value *Exn, Instruction *InsertBefore=0);
    2728 ResumeInst(Value *Exn, BasicBlock *InsertAtEnd);
    2729 protected:
    2730 virtual ResumeInst *clone_impl() const;
    2731 public:
    2732 static ResumeInst *Create(Value *Exn, Instruction *InsertBefore = 0) {
    2733 return new(1) ResumeInst(Exn, InsertBefore);
    2734 }
    2735 static ResumeInst *Create(Value *Exn, BasicBlock *InsertAtEnd) {
    2736 return new(1) ResumeInst(Exn, InsertAtEnd);
    2737 }
    2738
    2739 /// Provide fast operand accessors
    2740 DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
    2741
    2742 /// Convenience accessor.
    2743 Value *getValue() const { return Op<0>(); }
    2744
    2745 unsigned getNumSuccessors() const { return 0; }
    2746
    2747 // Methods for support type inquiry through isa, cast, and dyn_cast:
    2748 static inline bool classof(const ResumeInst *) { return true; }
    2749 static inline bool classof(const Instruction *I) {
    2750 return I->getOpcode() == Instruction::Resume;
    2751 }
    2752 static inline bool classof(const Value *V) {
    2753 return isa(V) && classof(cast(V));
    2754 }
    2755 private:
    2756 virtual BasicBlock *getSuccessorV(unsigned idx) const;
    2757 virtual unsigned getNumSuccessorsV() const;
    2758 virtual void setSuccessorV(unsigned idx, BasicBlock *B);
    2759 };
    2760
    2761 template <>
    2762 struct OperandTraits :
    2763 public FixedNumOperandTraits {
    2764 };
    2765
    2766 DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ResumeInst, Value)
    2767
    2768 //===----------------------------------------------------------------------===//
    27182769 // UnreachableInst Class
    27192770 //===----------------------------------------------------------------------===//
    27202771
    478478 return Insert(new UnwindInst(Context));
    479479 }
    480480
    481 ResumeInst *CreateResume(Value *Exn) {
    482 return Insert(ResumeInst::Create(Exn));
    483 }
    484
    481485 UnreachableInst *CreateUnreachable() {
    482486 return Insert(new UnreachableInst(Context));
    483487 }
    162162 RetTy visitIndirectBrInst(IndirectBrInst &I) { DELEGATE(TerminatorInst);}
    163163 RetTy visitInvokeInst(InvokeInst &I) { DELEGATE(TerminatorInst);}
    164164 RetTy visitUnwindInst(UnwindInst &I) { DELEGATE(TerminatorInst);}
    165 RetTy visitResumeInst(ResumeInst &I) { DELEGATE(TerminatorInst);}
    165166 RetTy visitUnreachableInst(UnreachableInst &I) { DELEGATE(TerminatorInst);}
    166167 RetTy visitICmpInst(ICmpInst &I) { DELEGATE(CmpInst);}
    167168 RetTy visitFCmpInst(FCmpInst &I) { DELEGATE(CmpInst);}
    187187 /* Atomic operators */
    188188 LLVMFence = 55,
    189189 LLVMAtomicCmpXchg = 56,
    190 LLVMAtomicRMW = 57
    190 LLVMAtomicRMW = 57,
    191
    192 /* Exception Handling Operators */
    193 LLVMResume = 58
    191194
    192195 } LLVMOpcode;
    193196
    476479 macro(SwitchInst) \
    477480 macro(UnreachableInst) \
    478481 macro(UnwindInst) \
    482 macro(ResumeInst) \
    479483 macro(UnaryInstruction) \
    480484 macro(AllocaInst) \
    481485 macro(CastInst) \
    824828 LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
    825829 const char *Name);
    826830 LLVMValueRef LLVMBuildUnwind(LLVMBuilderRef);
    831 LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn);
    827832 LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);
    828833
    829834 /* Add a case to the switch instruction */
    635635 INSTKEYWORD(switch, Switch);
    636636 INSTKEYWORD(indirectbr, IndirectBr);
    637637 INSTKEYWORD(invoke, Invoke);
    638 INSTKEYWORD(resume, Resume);
    638639 INSTKEYWORD(unwind, Unwind);
    639640 INSTKEYWORD(unreachable, Unreachable);
    640641
    28842884 case lltok::kw_switch: return ParseSwitch(Inst, PFS);
    28852885 case lltok::kw_indirectbr: return ParseIndirectBr(Inst, PFS);
    28862886 case lltok::kw_invoke: return ParseInvoke(Inst, PFS);
    2887 case lltok::kw_resume: return ParseResume(Inst, PFS);
    28872888 // Binary Operators.
    28882889 case lltok::kw_add:
    28892890 case lltok::kw_sub:
    32523253 return false;
    32533254 }
    32543255
    3255
    3256 /// ParseResume
    3257 /// ::= 'resume' TypeAndValue
    3258 bool LLParser::ParseResume(Instruction *&Inst, PerFunctionState &PFS) {
    3259 Value *Exn; LocTy ExnLoc;
    3260 LocTy Loc = Lex.getLoc();
    3261 if (ParseTypeAndValue(Exn, ExnLoc, PFS))
    3262 return true;
    3263
    3264 ResumeInst *RI = ResumeInst::Create(Exn);
    3265 Inst = RI;
    3266 return false;
    3267 }
    32563268
    32573269 //===----------------------------------------------------------------------===//
    32583270 // Binary Operators.
    346346 bool ParseSwitch(Instruction *&Inst, PerFunctionState &PFS);
    347347 bool ParseIndirectBr(Instruction *&Inst, PerFunctionState &PFS);
    348348 bool ParseInvoke(Instruction *&Inst, PerFunctionState &PFS);
    349 bool ParseResume(Instruction *&Inst, PerFunctionState &PFS);
    349350
    350351 bool ParseArithmetic(Instruction *&I, PerFunctionState &PFS, unsigned Opc,
    351352 unsigned OperandType);
    123123 kw_fptoui, kw_fptosi, kw_inttoptr, kw_ptrtoint, kw_bitcast,
    124124 kw_select, kw_va_arg,
    125125
    126 kw_ret, kw_br, kw_switch, kw_indirectbr, kw_invoke, kw_unwind,
    126 kw_ret, kw_br, kw_switch, kw_indirectbr, kw_invoke, kw_unwind, kw_resume,
    127127 kw_unreachable,
    128128
    129129 kw_alloca, kw_load, kw_store, kw_fence, kw_cmpxchg, kw_atomicrmw,
    25072507 cast(I)->setAttributes(PAL);
    25082508 break;
    25092509 }
    2510 case bitc::FUNC_CODE_INST_RESUME: { // RESUME: [opval]
    2511 unsigned Idx = 0;
    2512 Value *Val = 0;
    2513 if (getValueTypePair(Record, Idx, NextValueNo, Val))
    2514 return Error("Invalid RESUME record");
    2515 I = ResumeInst::Create(Val);
    2516 break;
    2517 }
    25102518 case bitc::FUNC_CODE_INST_UNWIND: // UNWIND
    25112519 I = new UnwindInst(Context);
    25122520 InstructionList.push_back(I);
    11421142 }
    11431143 break;
    11441144 }
    1145 case Instruction::Resume:
    1146 Code = bitc::FUNC_CODE_INST_RESUME;
    1147 PushValueAndType(I.getOperand(0), InstID, Vals, VE);
    1148 break;
    11451149 case Instruction::Unwind:
    11461150 Code = bitc::FUNC_CODE_INST_UNWIND;
    11471151 break;
    18071807 }
    18081808
    18091809 void SelectionDAGBuilder::visitUnwind(const UnwindInst &I) {
    1810 }
    1811
    1812 void SelectionDAGBuilder::visitResume(const ResumeInst &RI) {
    1813 llvm_unreachable("SelectionDAGBuilder shouldn't visit resume instructions!");
    18101814 }
    18111815
    18121816 /// handleSmallSwitchCaseRange - Emit a series of specific tests (suitable for
    466466 private:
    467467 // These all get lowered before this pass.
    468468 void visitInvoke(const InvokeInst &I);
    469 void visitResume(const ResumeInst &I);
    469470 void visitUnwind(const UnwindInst &I);
    470471
    471472 void visitBinary(const User &I, unsigned OpCode);
    112112 while (StateBB != StateE) {
    113113 BasicBlock *CurBB = StateBB++;
    114114
    115 // Branches and invokes do not escape, only unwind and return do.
    115 // Branches and invokes do not escape, only unwind, resume, and return
    116 // do.
    116117 TerminatorInst *TI = CurBB->getTerminator();
    117 if (!isa(TI) && !isa(TI))
    118 if (!isa(TI) && !isa(TI) &&
    119 !isa(TI))
    118120 continue;
    119121
    120122 Builder.SetInsertPoint(TI->getParent(), TI);
    287287 void visitInvokeInst(InvokeInst &I) {
    288288 llvm_unreachable("Lowerinvoke pass didn't work!");
    289289 }
    290
    291290 void visitUnwindInst(UnwindInst &I) {
    292291 llvm_unreachable("Lowerinvoke pass didn't work!");
    292 }
    293 void visitResumeInst(ResumeInst &I) {
    294 llvm_unreachable("DwarfEHPrepare pass didn't work!");
    293295 }
    294296 void visitUnreachableInst(UnreachableInst &I);
    295297
    10631063 }
    10641064 break;
    10651065 }
    1066 case Instruction::Resume: {
    1067 Out << "ResumeInst::Create(mod->getContext(), " << opNames[0]
    1068 << ", " << bbname << ");";
    1069 break;
    1070 }
    10661071 case Instruction::Invoke: {
    10671072 const InvokeInst* inv = cast(I);
    10681073 Out << "std::vector " << iName << "_params;";
    25052505 CallStack.pop_back(); // return from fn.
    25062506 return true; // We succeeded at evaluating this ctor!
    25072507 } else {
    2508 // invoke, unwind, unreachable.
    2508 // invoke, unwind, resume, unreachable.
    25092509 return false; // Cannot handle this terminator.
    25102510 }
    25112511
    731731 }
    732732 }
    733733
    734 // If the stack restore is in a return/unwind block and if there are no
    735 // allocas or calls between the restore and the return, nuke the restore.
    736 if (!CannotRemove && (isa(TI) || isa(TI)))
    734 // If the stack restore is in a return, resume, or unwind block and if there
    735 // are no allocas or calls between the restore and the return, nuke the
    736 // restore.
    737 if (!CannotRemove && (isa(TI) || isa(TI) ||
    738 isa(TI)))
    737739 return EraseInstFromFunction(CI);
    738740 break;
    739741 }
    527527 visitTerminatorInst(II);
    528528 }
    529529 void visitCallSite (CallSite CS);
    530 void visitResumeInst (TerminatorInst &I) { /*returns void*/ }
    530531 void visitUnwindInst (TerminatorInst &I) { /*returns void*/ }
    531532 void visitUnreachableInst(TerminatorInst &I) { /*returns void*/ }
    532533 void visitFenceInst (FenceInst &I) { /*returns void*/ }
    16861686 return wrap(unwrap(B)->CreateUnwind());
    16871687 }
    16881688
    1689 LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn) {
    1690 return wrap(unwrap(B)->CreateResume(unwrap(Exn)));
    1691 }
    1692
    16891693 LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef B) {
    16901694 return wrap(unwrap(B)->CreateUnreachable());
    16911695 }
    100100 case Switch: return "switch";
    101101 case IndirectBr: return "indirectbr";
    102102 case Invoke: return "invoke";
    103 case Resume: return "resume";
    103104 case Unwind: return "unwind";
    104105 case Unreachable: return "unreachable";
    105106
    569569
    570570 BasicBlock *UnwindInst::getSuccessorV(unsigned idx) const {
    571571 llvm_unreachable("UnwindInst has no successors!");
    572 return 0;
    573 }
    574
    575 //===----------------------------------------------------------------------===//
    576 // ResumeInst Implementation
    577 //===----------------------------------------------------------------------===//
    578
    579 ResumeInst::ResumeInst(const ResumeInst &RI)
    580 : TerminatorInst(Type::getVoidTy(RI.getContext()), Instruction::Resume,
    581 OperandTraits::op_begin(this), 1) {
    582 Op<0>() = RI.Op<0>();
    583 }
    584
    585 ResumeInst::ResumeInst(Value *Exn, Instruction *InsertBefore)
    586 : TerminatorInst(Type::getVoidTy(Exn->getContext()), Instruction::Resume,
    587 OperandTraits::op_begin(this), 1, InsertBefore) {
    588 Op<0>() = Exn;
    589 }
    590
    591 ResumeInst::ResumeInst(Value *Exn, BasicBlock *InsertAtEnd)
    592 : TerminatorInst(Type::getVoidTy(Exn->getContext()), Instruction::Resume,
    593 OperandTraits::op_begin(this), 1, InsertAtEnd) {
    594 Op<0>() = Exn;
    595 }
    596
    597 unsigned ResumeInst::getNumSuccessorsV() const {
    598 return getNumSuccessors();
    599 }
    600
    601 void ResumeInst::setSuccessorV(unsigned idx, BasicBlock *NewSucc) {
    602 llvm_unreachable("ResumeInst has no successors!");
    603 }
    604
    605 BasicBlock *ResumeInst::getSuccessorV(unsigned idx) const {
    606 llvm_unreachable("ResumeInst has no successors!");
    572607 return 0;
    573608 }
    574609
    32533288 return new(getNumOperands()) InvokeInst(*this);
    32543289 }
    32553290
    3291 ResumeInst *ResumeInst::clone_impl() const {
    3292 return new(1) ResumeInst(*this);
    3293 }
    3294
    32563295 UnwindInst *UnwindInst::clone_impl() const {
    32573296 LLVMContext &Context = getContext();
    32583297 return new UnwindInst(Context);