[llvm-branch-commits] [llvm-branch] r136038 - in /llvm/branches/exception-handling-rewrite: include/llvm/ include/llvm/Bitcode/ include/llvm/Support/ lib/AsmParser/ lib/Bitcode/Reader/ lib/Bitcode/Writer/ lib/CodeGen/SelectionDAG/ lib/VMCore/

Bill Wendling isanbard at gmail.com
Mon Jul 25 18:17:04 PDT 2011


Author: void
Date: Mon Jul 25 20:17:04 2011
New Revision: 136038

URL: http://llvm.org/viewvc/llvm-project?rev=136038&view=rev
Log:
Add the 'resume' instruction.

The 'resume' instruction is a new terminator. It takes the value returned by the
landingpad instruction as its only argument. It will resume propagating the
exception.

Modified:
    llvm/branches/exception-handling-rewrite/include/llvm/Bitcode/LLVMBitCodes.h
    llvm/branches/exception-handling-rewrite/include/llvm/Instruction.def
    llvm/branches/exception-handling-rewrite/include/llvm/Instructions.h
    llvm/branches/exception-handling-rewrite/include/llvm/Support/InstVisitor.h
    llvm/branches/exception-handling-rewrite/lib/AsmParser/LLLexer.cpp
    llvm/branches/exception-handling-rewrite/lib/AsmParser/LLParser.cpp
    llvm/branches/exception-handling-rewrite/lib/AsmParser/LLParser.h
    llvm/branches/exception-handling-rewrite/lib/AsmParser/LLToken.h
    llvm/branches/exception-handling-rewrite/lib/Bitcode/Reader/BitcodeReader.cpp
    llvm/branches/exception-handling-rewrite/lib/Bitcode/Writer/BitcodeWriter.cpp
    llvm/branches/exception-handling-rewrite/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
    llvm/branches/exception-handling-rewrite/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
    llvm/branches/exception-handling-rewrite/lib/VMCore/AsmWriter.cpp
    llvm/branches/exception-handling-rewrite/lib/VMCore/Instruction.cpp
    llvm/branches/exception-handling-rewrite/lib/VMCore/Instructions.cpp

Modified: llvm/branches/exception-handling-rewrite/include/llvm/Bitcode/LLVMBitCodes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/exception-handling-rewrite/include/llvm/Bitcode/LLVMBitCodes.h?rev=136038&r1=136037&r2=136038&view=diff
==============================================================================
--- llvm/branches/exception-handling-rewrite/include/llvm/Bitcode/LLVMBitCodes.h (original)
+++ llvm/branches/exception-handling-rewrite/include/llvm/Bitcode/LLVMBitCodes.h Mon Jul 25 20:17:04 2011
@@ -240,7 +240,7 @@
     FUNC_CODE_INST_UNREACHABLE = 15, // UNREACHABLE
 
     FUNC_CODE_INST_PHI         = 16, // PHI:        [ty, val0,bb0, ...]
-    // 17 is unused.
+    FUNC_CODE_INST_RESUME      = 17, // RESUME:     [opval]
     // 18 is unused.
     FUNC_CODE_INST_ALLOCA      = 19, // ALLOCA:     [instty, op, align]
     FUNC_CODE_INST_LOAD        = 20, // LOAD:       [opty, op, align, vol]

Modified: llvm/branches/exception-handling-rewrite/include/llvm/Instruction.def
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/exception-handling-rewrite/include/llvm/Instruction.def?rev=136038&r1=136037&r2=136038&view=diff
==============================================================================
--- llvm/branches/exception-handling-rewrite/include/llvm/Instruction.def (original)
+++ llvm/branches/exception-handling-rewrite/include/llvm/Instruction.def Mon Jul 25 20:17:04 2011
@@ -100,77 +100,77 @@
 HANDLE_TERM_INST  ( 4, IndirectBr , IndirectBrInst)
 HANDLE_TERM_INST  ( 5, Invoke     , InvokeInst)
 HANDLE_TERM_INST  ( 6, Unwind     , UnwindInst)
-HANDLE_TERM_INST  ( 7, Unreachable, UnreachableInst)
-  LAST_TERM_INST  ( 7)
+HANDLE_TERM_INST  ( 7, Resume     , ResumeInst)
+HANDLE_TERM_INST  ( 8, Unreachable, UnreachableInst)
+  LAST_TERM_INST  ( 8)
 
 // Standard binary operators...
- FIRST_BINARY_INST( 8)
-HANDLE_BINARY_INST( 8, Add  , BinaryOperator)
-HANDLE_BINARY_INST( 9, FAdd  , BinaryOperator)
-HANDLE_BINARY_INST(10, Sub  , BinaryOperator)
-HANDLE_BINARY_INST(11, FSub  , BinaryOperator)
-HANDLE_BINARY_INST(12, Mul  , BinaryOperator)
-HANDLE_BINARY_INST(13, FMul  , BinaryOperator)
-HANDLE_BINARY_INST(14, UDiv , BinaryOperator)
-HANDLE_BINARY_INST(15, SDiv , BinaryOperator)
-HANDLE_BINARY_INST(16, FDiv , BinaryOperator)
-HANDLE_BINARY_INST(17, URem , BinaryOperator)
-HANDLE_BINARY_INST(18, SRem , BinaryOperator)
-HANDLE_BINARY_INST(19, FRem , BinaryOperator)
+ FIRST_BINARY_INST( 9)
+HANDLE_BINARY_INST( 9, Add  , BinaryOperator)
+HANDLE_BINARY_INST(10, FAdd  , BinaryOperator)
+HANDLE_BINARY_INST(11, Sub  , BinaryOperator)
+HANDLE_BINARY_INST(12, FSub  , BinaryOperator)
+HANDLE_BINARY_INST(13, Mul  , BinaryOperator)
+HANDLE_BINARY_INST(14, FMul  , BinaryOperator)
+HANDLE_BINARY_INST(15, UDiv , BinaryOperator)
+HANDLE_BINARY_INST(16, SDiv , BinaryOperator)
+HANDLE_BINARY_INST(17, FDiv , BinaryOperator)
+HANDLE_BINARY_INST(18, URem , BinaryOperator)
+HANDLE_BINARY_INST(19, SRem , BinaryOperator)
+HANDLE_BINARY_INST(20, FRem , BinaryOperator)
 
 // Logical operators (integer operands)
-HANDLE_BINARY_INST(20, Shl  , BinaryOperator) // Shift left  (logical)
-HANDLE_BINARY_INST(21, LShr , BinaryOperator) // Shift right (logical)
-HANDLE_BINARY_INST(22, AShr , BinaryOperator) // Shift right (arithmetic)
-HANDLE_BINARY_INST(23, And  , BinaryOperator)
-HANDLE_BINARY_INST(24, Or   , BinaryOperator)
-HANDLE_BINARY_INST(25, Xor  , BinaryOperator)
-  LAST_BINARY_INST(25)
+HANDLE_BINARY_INST(21, Shl  , BinaryOperator) // Shift left  (logical)
+HANDLE_BINARY_INST(22, LShr , BinaryOperator) // Shift right (logical)
+HANDLE_BINARY_INST(23, AShr , BinaryOperator) // Shift right (arithmetic)
+HANDLE_BINARY_INST(24, And  , BinaryOperator)
+HANDLE_BINARY_INST(25, Or   , BinaryOperator)
+HANDLE_BINARY_INST(26, Xor  , BinaryOperator)
+  LAST_BINARY_INST(26)
 
 // Memory operators...
- FIRST_MEMORY_INST(26)
-HANDLE_MEMORY_INST(26, Alloca, AllocaInst)  // Stack management
-HANDLE_MEMORY_INST(27, Load  , LoadInst  )  // Memory manipulation instrs
-HANDLE_MEMORY_INST(28, Store , StoreInst )
-HANDLE_MEMORY_INST(29, GetElementPtr, GetElementPtrInst)
-  LAST_MEMORY_INST(29)
+ FIRST_MEMORY_INST(27)
+HANDLE_MEMORY_INST(27, Alloca, AllocaInst)  // Stack management
+HANDLE_MEMORY_INST(28, Load  , LoadInst  )  // Memory manipulation instrs
+HANDLE_MEMORY_INST(29, Store , StoreInst )
+HANDLE_MEMORY_INST(30, GetElementPtr, GetElementPtrInst)
+  LAST_MEMORY_INST(30)
 
 // Cast operators ...
 // NOTE: The order matters here because CastInst::isEliminableCastPair 
 // NOTE: (see Instructions.cpp) encodes a table based on this ordering.
- FIRST_CAST_INST(30)
-HANDLE_CAST_INST(30, Trunc   , TruncInst   )  // Truncate integers
-HANDLE_CAST_INST(31, ZExt    , ZExtInst    )  // Zero extend integers
-HANDLE_CAST_INST(32, SExt    , SExtInst    )  // Sign extend integers
-HANDLE_CAST_INST(33, FPToUI  , FPToUIInst  )  // floating point -> UInt
-HANDLE_CAST_INST(34, FPToSI  , FPToSIInst  )  // floating point -> SInt
-HANDLE_CAST_INST(35, UIToFP  , UIToFPInst  )  // UInt -> floating point
-HANDLE_CAST_INST(36, SIToFP  , SIToFPInst  )  // SInt -> floating point
-HANDLE_CAST_INST(37, FPTrunc , FPTruncInst )  // Truncate floating point
-HANDLE_CAST_INST(38, FPExt   , FPExtInst   )  // Extend floating point
-HANDLE_CAST_INST(39, PtrToInt, PtrToIntInst)  // Pointer -> Integer
-HANDLE_CAST_INST(40, IntToPtr, IntToPtrInst)  // Integer -> Pointer
-HANDLE_CAST_INST(41, BitCast , BitCastInst )  // Type cast
-  LAST_CAST_INST(41)
+ FIRST_CAST_INST(31)
+HANDLE_CAST_INST(31, Trunc   , TruncInst   )  // Truncate integers
+HANDLE_CAST_INST(32, ZExt    , ZExtInst    )  // Zero extend integers
+HANDLE_CAST_INST(33, SExt    , SExtInst    )  // Sign extend integers
+HANDLE_CAST_INST(34, FPToUI  , FPToUIInst  )  // floating point -> UInt
+HANDLE_CAST_INST(35, FPToSI  , FPToSIInst  )  // floating point -> SInt
+HANDLE_CAST_INST(36, UIToFP  , UIToFPInst  )  // UInt -> floating point
+HANDLE_CAST_INST(37, SIToFP  , SIToFPInst  )  // SInt -> floating point
+HANDLE_CAST_INST(38, FPTrunc , FPTruncInst )  // Truncate floating point
+HANDLE_CAST_INST(39, FPExt   , FPExtInst   )  // Extend floating point
+HANDLE_CAST_INST(40, PtrToInt, PtrToIntInst)  // Pointer -> Integer
+HANDLE_CAST_INST(41, IntToPtr, IntToPtrInst)  // Integer -> Pointer
+HANDLE_CAST_INST(42, BitCast , BitCastInst )  // Type cast
+  LAST_CAST_INST(42)
 
 // Other operators...
- FIRST_OTHER_INST(42)
-HANDLE_OTHER_INST(42, ICmp   , ICmpInst   )  // Integer comparison instruction
-HANDLE_OTHER_INST(43, FCmp   , FCmpInst   )  // Floating point comparison instr.
-HANDLE_OTHER_INST(44, PHI    , PHINode    )  // PHI node instruction
-HANDLE_OTHER_INST(45, Call   , CallInst   )  // Call a function
-HANDLE_OTHER_INST(46, Select , SelectInst )  // select instruction
-HANDLE_OTHER_INST(47, UserOp1, Instruction)  // May be used internally in a pass
-HANDLE_OTHER_INST(48, UserOp2, Instruction)  // Internal to passes only
-HANDLE_OTHER_INST(49, VAArg  , VAArgInst  )  // vaarg instruction
-HANDLE_OTHER_INST(50, ExtractElement, ExtractElementInst)// extract from vector
-HANDLE_OTHER_INST(51, InsertElement, InsertElementInst)  // insert into vector
-HANDLE_OTHER_INST(52, ShuffleVector, ShuffleVectorInst)  // shuffle two vectors.
-HANDLE_OTHER_INST(53, ExtractValue, ExtractValueInst)// extract from aggregate
-HANDLE_OTHER_INST(54, InsertValue, InsertValueInst)  // insert into aggregate
-HANDLE_OTHER_INST(55, LandingPad, LandingPadInst)  // Landing pad instruction.
-
-  LAST_OTHER_INST(55)
+ FIRST_OTHER_INST(43)
+HANDLE_OTHER_INST(43, ICmp   , ICmpInst   )  // Integer comparison instruction
+HANDLE_OTHER_INST(44, FCmp   , FCmpInst   )  // Floating point comparison instr.
+HANDLE_OTHER_INST(45, PHI    , PHINode    )  // PHI node instruction
+HANDLE_OTHER_INST(46, Call   , CallInst   )  // Call a function
+HANDLE_OTHER_INST(47, Select , SelectInst )  // select instruction
+HANDLE_OTHER_INST(48, UserOp1, Instruction)  // May be used internally in a pass
+HANDLE_OTHER_INST(49, UserOp2, Instruction)  // Internal to passes only
+HANDLE_OTHER_INST(50, VAArg  , VAArgInst  )  // vaarg instruction
+HANDLE_OTHER_INST(51, ExtractElement, ExtractElementInst)// extract from vector
+HANDLE_OTHER_INST(52, InsertElement, InsertElementInst)  // insert into vector
+HANDLE_OTHER_INST(53, ShuffleVector, ShuffleVectorInst)  // shuffle two vectors.
+HANDLE_OTHER_INST(54, ExtractValue, ExtractValueInst)// extract from aggregate
+HANDLE_OTHER_INST(55, InsertValue, InsertValueInst)  // insert into aggregate
+HANDLE_OTHER_INST(56, LandingPad, LandingPadInst)  // Landing pad instruction.
+  LAST_OTHER_INST(56)
 
 #undef  FIRST_TERM_INST
 #undef HANDLE_TERM_INST

Modified: llvm/branches/exception-handling-rewrite/include/llvm/Instructions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/exception-handling-rewrite/include/llvm/Instructions.h?rev=136038&r1=136037&r2=136038&view=diff
==============================================================================
--- llvm/branches/exception-handling-rewrite/include/llvm/Instructions.h (original)
+++ llvm/branches/exception-handling-rewrite/include/llvm/Instructions.h Mon Jul 25 20:17:04 2011
@@ -1808,6 +1808,12 @@
 //                           LandingPadInst Class
 //===----------------------------------------------------------------------===//
 
+//===---------------------------------------------------------------------------
+/// LandingPadInst - The landingpad instruction holds all of the information
+/// necessary to generate correct exception handling. The landingpad instruction
+/// cannot be moved from the top of a landing pad block, which itself is
+/// accessible only from the 'unwind' edge of an invoke.
+///
 class LandingPadInst : public Instruction {
   /// ReservedSpace - The number of operands actually allocated.  NumOperands is
   /// the number actually in use.
@@ -2587,6 +2593,59 @@
 };
 
 //===----------------------------------------------------------------------===//
+//                              ResumeInst Class
+//===----------------------------------------------------------------------===//
+
+//===---------------------------------------------------------------------------
+/// ResumeInst - Resume the propagation of an exception.
+///
+class ResumeInst : public TerminatorInst {
+  ResumeInst(const ResumeInst &RI);
+
+  explicit ResumeInst(LLVMContext &C, Value *Exn, Instruction *InsertBefore=0);
+  ResumeInst(LLVMContext &C, Value *Exn, BasicBlock *InsertAtEnd);
+protected:
+  virtual ResumeInst *clone_impl() const;
+public:
+  static ResumeInst *Create(LLVMContext &C, Value *Exn,
+                            Instruction *InsertBefore = 0) {
+    return new(1) ResumeInst(C, Exn, InsertBefore);
+  }
+  static ResumeInst *Create(LLVMContext &C, Value *Exn,
+                            BasicBlock *InsertAtEnd) {
+    return new(1) ResumeInst(C, Exn, InsertAtEnd);
+  }
+
+  /// Provide fast operand accessors
+  DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
+
+  /// Convenience accessor.
+  Value *getResumeValue() const { return Op<0>(); }
+
+  unsigned getNumSuccessors() const { return 0; }
+
+  // Methods for support type inquiry through isa, cast, and dyn_cast:
+  static inline bool classof(const ResumeInst *) { return true; }
+  static inline bool classof(const Instruction *I) {
+    return I->getOpcode() == Instruction::Resume;
+  }
+  static inline bool classof(const Value *V) {
+    return isa<Instruction>(V) && classof(cast<Instruction>(V));
+  }
+private:
+  virtual BasicBlock *getSuccessorV(unsigned idx) const;
+  virtual unsigned getNumSuccessorsV() const;
+  virtual void setSuccessorV(unsigned idx, BasicBlock *B);
+};
+
+template <>
+struct OperandTraits<ResumeInst> :
+    public FixedNumOperandTraits<ResumeInst, 1> {
+};
+
+DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ResumeInst, Value)
+
+//===----------------------------------------------------------------------===//
 //                           UnreachableInst Class
 //===----------------------------------------------------------------------===//
 

Modified: llvm/branches/exception-handling-rewrite/include/llvm/Support/InstVisitor.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/exception-handling-rewrite/include/llvm/Support/InstVisitor.h?rev=136038&r1=136037&r2=136038&view=diff
==============================================================================
--- llvm/branches/exception-handling-rewrite/include/llvm/Support/InstVisitor.h (original)
+++ llvm/branches/exception-handling-rewrite/include/llvm/Support/InstVisitor.h Mon Jul 25 20:17:04 2011
@@ -163,6 +163,7 @@
   RetTy visitIndirectBrInst(IndirectBrInst &I)      { DELEGATE(TerminatorInst);}
   RetTy visitInvokeInst(InvokeInst &I)              { DELEGATE(TerminatorInst);}
   RetTy visitUnwindInst(UnwindInst &I)              { DELEGATE(TerminatorInst);}
+  RetTy visitResumeInst(ResumeInst &I)              { DELEGATE(TerminatorInst);}
   RetTy visitUnreachableInst(UnreachableInst &I)    { DELEGATE(TerminatorInst);}
   RetTy visitICmpInst(ICmpInst &I)                  { DELEGATE(CmpInst);}
   RetTy visitFCmpInst(FCmpInst &I)                  { DELEGATE(CmpInst);}

Modified: llvm/branches/exception-handling-rewrite/lib/AsmParser/LLLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/exception-handling-rewrite/lib/AsmParser/LLLexer.cpp?rev=136038&r1=136037&r2=136038&view=diff
==============================================================================
--- llvm/branches/exception-handling-rewrite/lib/AsmParser/LLLexer.cpp (original)
+++ llvm/branches/exception-handling-rewrite/lib/AsmParser/LLLexer.cpp Mon Jul 25 20:17:04 2011
@@ -628,6 +628,7 @@
   INSTKEYWORD(switch,      Switch);
   INSTKEYWORD(indirectbr,  IndirectBr);
   INSTKEYWORD(invoke,      Invoke);
+  INSTKEYWORD(resume,      Resume);
   INSTKEYWORD(unwind,      Unwind);
   INSTKEYWORD(unreachable, Unreachable);
 

Modified: llvm/branches/exception-handling-rewrite/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/exception-handling-rewrite/lib/AsmParser/LLParser.cpp?rev=136038&r1=136037&r2=136038&view=diff
==============================================================================
--- llvm/branches/exception-handling-rewrite/lib/AsmParser/LLParser.cpp (original)
+++ llvm/branches/exception-handling-rewrite/lib/AsmParser/LLParser.cpp Mon Jul 25 20:17:04 2011
@@ -2861,6 +2861,7 @@
   case lltok::kw_switch:      return ParseSwitch(Inst, PFS);
   case lltok::kw_indirectbr:  return ParseIndirectBr(Inst, PFS);
   case lltok::kw_invoke:      return ParseInvoke(Inst, PFS);
+  case lltok::kw_resume:      return ParseResume(Inst, PFS);
   // Binary Operators.
   case lltok::kw_add:
   case lltok::kw_sub:
@@ -3223,7 +3224,18 @@
   return false;
 }
 
+/// ParseResume
+///   ::= 'resume' TypeAndValue
+bool LLParser::ParseResume(Instruction *&Inst, PerFunctionState &PFS) {
+  Value *Exn; LocTy ExnLoc;
+  LocTy Loc = Lex.getLoc();
+  if (ParseTypeAndValue(Exn, ExnLoc, PFS))
+    return true;
 
+  ResumeInst *RI = ResumeInst::Create(Context, Exn);
+  Inst = RI;
+  return false;
+}
 
 //===----------------------------------------------------------------------===//
 // Binary Operators.

Modified: llvm/branches/exception-handling-rewrite/lib/AsmParser/LLParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/exception-handling-rewrite/lib/AsmParser/LLParser.h?rev=136038&r1=136037&r2=136038&view=diff
==============================================================================
--- llvm/branches/exception-handling-rewrite/lib/AsmParser/LLParser.h (original)
+++ llvm/branches/exception-handling-rewrite/lib/AsmParser/LLParser.h Mon Jul 25 20:17:04 2011
@@ -344,6 +344,7 @@
     bool ParseSwitch(Instruction *&Inst, PerFunctionState &PFS);
     bool ParseIndirectBr(Instruction *&Inst, PerFunctionState &PFS);
     bool ParseInvoke(Instruction *&Inst, PerFunctionState &PFS);
+    bool ParseResume(Instruction *&Inst, PerFunctionState &PFS);
 
     bool ParseArithmetic(Instruction *&I, PerFunctionState &PFS, unsigned Opc,
                          unsigned OperandType);

Modified: llvm/branches/exception-handling-rewrite/lib/AsmParser/LLToken.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/exception-handling-rewrite/lib/AsmParser/LLToken.h?rev=136038&r1=136037&r2=136038&view=diff
==============================================================================
--- llvm/branches/exception-handling-rewrite/lib/AsmParser/LLToken.h (original)
+++ llvm/branches/exception-handling-rewrite/lib/AsmParser/LLToken.h Mon Jul 25 20:17:04 2011
@@ -120,7 +120,7 @@
 
     kw_landingpad, kw_personality, kw_catch, kw_filter,
 
-    kw_ret, kw_br, kw_switch, kw_indirectbr, kw_invoke, kw_unwind,
+    kw_ret, kw_br, kw_switch, kw_indirectbr, kw_invoke, kw_unwind, kw_resume,
     kw_unreachable,
 
     kw_alloca, kw_load, kw_store, kw_getelementptr,

Modified: llvm/branches/exception-handling-rewrite/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/exception-handling-rewrite/lib/Bitcode/Reader/BitcodeReader.cpp?rev=136038&r1=136037&r2=136038&view=diff
==============================================================================
--- llvm/branches/exception-handling-rewrite/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/branches/exception-handling-rewrite/lib/Bitcode/Reader/BitcodeReader.cpp Mon Jul 25 20:17:04 2011
@@ -2470,6 +2470,14 @@
       cast<InvokeInst>(I)->setAttributes(PAL);
       break;
     }
+    case bitc::FUNC_CODE_INST_RESUME: { // RESUME: [opval]
+      unsigned Idx = 0;
+      Value *Val = 0;
+      if (getValueTypePair(Record, Idx, NextValueNo, Val))
+        return Error("Invalid RESUME record");
+      I = ResumeInst::Create(Context, Val);
+      break;
+    }
     case bitc::FUNC_CODE_INST_UNWIND: // UNWIND
       I = new UnwindInst(Context);
       InstructionList.push_back(I);

Modified: llvm/branches/exception-handling-rewrite/lib/Bitcode/Writer/BitcodeWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/exception-handling-rewrite/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=136038&r1=136037&r2=136038&view=diff
==============================================================================
--- llvm/branches/exception-handling-rewrite/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
+++ llvm/branches/exception-handling-rewrite/lib/Bitcode/Writer/BitcodeWriter.cpp Mon Jul 25 20:17:04 2011
@@ -1105,6 +1105,10 @@
     }
     break;
   }
+  case Instruction::Resume:
+    Code = bitc::FUNC_CODE_INST_RESUME;
+    PushValueAndType(I.getOperand(0), InstID, Vals, VE);
+    break;
   case Instruction::Unwind:
     Code = bitc::FUNC_CODE_INST_UNWIND;
     break;

Modified: llvm/branches/exception-handling-rewrite/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/exception-handling-rewrite/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=136038&r1=136037&r2=136038&view=diff
==============================================================================
--- llvm/branches/exception-handling-rewrite/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original)
+++ llvm/branches/exception-handling-rewrite/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Mon Jul 25 20:17:04 2011
@@ -1813,6 +1813,10 @@
 void SelectionDAGBuilder::visitUnwind(const UnwindInst &I) {
 }
 
+void SelectionDAGBuilder::visitResume(const ResumeInst &RI) {
+  // FIXME: Handle this
+}
+
 /// handleSmallSwitchCaseRange - Emit a series of specific tests (suitable for
 /// small case ranges).
 bool SelectionDAGBuilder::handleSmallSwitchRange(CaseRec& CR,

Modified: llvm/branches/exception-handling-rewrite/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/exception-handling-rewrite/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h?rev=136038&r1=136037&r2=136038&view=diff
==============================================================================
--- llvm/branches/exception-handling-rewrite/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h (original)
+++ llvm/branches/exception-handling-rewrite/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h Mon Jul 25 20:17:04 2011
@@ -453,6 +453,7 @@
 private:
   // These all get lowered before this pass.
   void visitInvoke(const InvokeInst &I);
+  void visitResume(const ResumeInst &I);
   void visitUnwind(const UnwindInst &I);
 
   void visitBinary(const User &I, unsigned OpCode);

Modified: llvm/branches/exception-handling-rewrite/lib/VMCore/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/exception-handling-rewrite/lib/VMCore/AsmWriter.cpp?rev=136038&r1=136037&r2=136038&view=diff
==============================================================================
--- llvm/branches/exception-handling-rewrite/lib/VMCore/AsmWriter.cpp (original)
+++ llvm/branches/exception-handling-rewrite/lib/VMCore/AsmWriter.cpp Mon Jul 25 20:17:04 2011
@@ -1687,6 +1687,9 @@
       writeOperand(I.getOperand(i), true);
     }
     Out << ']';
+  } else if (isa<ResumeInst>(I)) {
+    Out << ' ';
+    writeOperand(Operand, true);
   } else if (const PHINode *PN = dyn_cast<PHINode>(&I)) {
     Out << ' ';
     TypePrinter.print(I.getType(), Out);

Modified: llvm/branches/exception-handling-rewrite/lib/VMCore/Instruction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/exception-handling-rewrite/lib/VMCore/Instruction.cpp?rev=136038&r1=136037&r2=136038&view=diff
==============================================================================
--- llvm/branches/exception-handling-rewrite/lib/VMCore/Instruction.cpp (original)
+++ llvm/branches/exception-handling-rewrite/lib/VMCore/Instruction.cpp Mon Jul 25 20:17:04 2011
@@ -101,6 +101,7 @@
   case Switch: return "switch";
   case IndirectBr: return "indirectbr";
   case Invoke: return "invoke";
+  case Resume: return "resume";
   case Unwind: return "unwind";
   case Unreachable: return "unreachable";
 

Modified: llvm/branches/exception-handling-rewrite/lib/VMCore/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/exception-handling-rewrite/lib/VMCore/Instructions.cpp?rev=136038&r1=136037&r2=136038&view=diff
==============================================================================
--- llvm/branches/exception-handling-rewrite/lib/VMCore/Instructions.cpp (original)
+++ llvm/branches/exception-handling-rewrite/lib/VMCore/Instructions.cpp Mon Jul 25 20:17:04 2011
@@ -627,6 +627,42 @@
 }
 
 //===----------------------------------------------------------------------===//
+//                        ResumeInst Implementation
+//===----------------------------------------------------------------------===//
+
+ResumeInst::ResumeInst(const ResumeInst &RI)
+  : TerminatorInst(Type::getVoidTy(RI.getContext()), Instruction::Resume,
+                   OperandTraits<ResumeInst>::op_begin(this), 1) {
+  Op<0>() = RI.Op<0>();
+  SubclassOptionalData = RI.SubclassOptionalData;
+}
+
+ResumeInst::ResumeInst(LLVMContext &C, Value *Exn, Instruction *InsertBefore)
+  : TerminatorInst(Type::getVoidTy(C), Instruction::Resume,
+                   OperandTraits<ResumeInst>::op_begin(this), 1, InsertBefore) {
+  Op<0>() = Exn;
+}
+
+ResumeInst::ResumeInst(LLVMContext &C, Value *Exn, BasicBlock *InsertAtEnd)
+  : TerminatorInst(Type::getVoidTy(C), Instruction::Resume,
+                   OperandTraits<ResumeInst>::op_begin(this), 1, InsertAtEnd) {
+  Op<0>() = Exn;
+}
+
+unsigned ResumeInst::getNumSuccessorsV() const {
+  return getNumSuccessors();
+}
+
+void ResumeInst::setSuccessorV(unsigned idx, BasicBlock *NewSucc) {
+  llvm_unreachable("ResumeInst has no successors!");
+}
+
+BasicBlock *ResumeInst::getSuccessorV(unsigned idx) const {
+  llvm_unreachable("ResumeInst has no successors!");
+  return 0;
+}
+
+//===----------------------------------------------------------------------===//
 //                      UnreachableInst Implementation
 //===----------------------------------------------------------------------===//
 
@@ -645,11 +681,11 @@
 }
 
 void UnreachableInst::setSuccessorV(unsigned idx, BasicBlock *NewSucc) {
-  llvm_unreachable("UnwindInst has no successors!");
+  llvm_unreachable("UnreachableInst has no successors!");
 }
 
 BasicBlock *UnreachableInst::getSuccessorV(unsigned idx) const {
-  llvm_unreachable("UnwindInst has no successors!");
+  llvm_unreachable("UnreachableInst has no successors!");
   return 0;
 }
 
@@ -3233,6 +3269,10 @@
   return new(getNumOperands()) InvokeInst(*this);
 }
 
+ResumeInst *ResumeInst::clone_impl() const {
+  return new(1) ResumeInst(*this);
+}
+
 UnwindInst *UnwindInst::clone_impl() const {
   LLVMContext &Context = getContext();
   return new UnwindInst(Context);





More information about the llvm-branch-commits mailing list