]> granicus.if.org Git - clang/commitdiff
Ensure we only generate one terminate handler.
authorMike Stump <mrs@apple.com>
Thu, 10 Dec 2009 00:02:42 +0000 (00:02 +0000)
committerMike Stump <mrs@apple.com>
Thu, 10 Dec 2009 00:02:42 +0000 (00:02 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90998 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGException.cpp
lib/CodeGen/CodeGenFunction.cpp
lib/CodeGen/CodeGenFunction.h

index 13780b39bbad890807f43292732ebcba2ed8e6f9..9f4d50ccb7c51e9e7f6ef195a9b6a795d2eb6f9b 100644 (file)
@@ -683,6 +683,9 @@ CodeGenFunction::EHCleanupBlock::~EHCleanupBlock() {
 }
 
 llvm::BasicBlock *CodeGenFunction::getTerminateHandler() {
+  if (TerminateHandler)
+    return TerminateHandler;
+
   llvm::BasicBlock *Cont = 0;
 
   if (HaveInsertPoint()) {
@@ -702,7 +705,7 @@ llvm::BasicBlock *CodeGenFunction::getTerminateHandler() {
     CGM.getIntrinsic(llvm::Intrinsic::eh_selector);
 
   // Set up terminate handler
-  llvm::BasicBlock *TerminateHandler = createBasicBlock("terminate.handler");
+  TerminateHandler = createBasicBlock("terminate.handler");
   EmitBlock(TerminateHandler);
   llvm::Value *Exc = Builder.CreateCall(llvm_eh_exception, "exc");
   // We are required to emit this call to satisfy LLVM, even
index adfd75b42a75dd5f26c42608a45e55cf445e1991..18442bb159038b4f317b8618251bd643a8606fb4 100644 (file)
@@ -31,7 +31,7 @@ CodeGenFunction::CodeGenFunction(CodeGenModule &cgm)
     DebugInfo(0), IndirectBranch(0),
     SwitchInsn(0), CaseRangeBlock(0), InvokeDest(0),
     CXXThisDecl(0), CXXVTTDecl(0),
-    ConditionalBranchLevel(0) {
+    ConditionalBranchLevel(0), TerminateHandler(0) {
   LLVMIntTy = ConvertType(getContext().IntTy);
   LLVMPointerWidth = Target.getPointerWidth(0);
   Exceptions = getContext().getLangOptions().Exceptions;
index 7ef3ad0422ffdf5f35c6ec648f25b86b53eb3adc..cf267c416763d3f4148e7285e7c07896182e7795 100644 (file)
@@ -422,6 +422,8 @@ private:
   /// getByrefValueFieldNumber - Given a declaration, returns the LLVM field
   /// number that holds the value.
   unsigned getByRefValueLLVMField(const ValueDecl *VD) const;
+
+  llvm::BasicBlock *TerminateHandler;
   
 public:
   CodeGenFunction(CodeGenModule &cgm);
@@ -552,6 +554,7 @@ public:
   /// EmitEndEHSpec - Emit the end of the exception spec.
   void EmitEndEHSpec(const Decl *D);
 
+  /// getTerminateHandler - Return a handler that just calls terminate.
   llvm::BasicBlock *getTerminateHandler();
 
   const llvm::Type *ConvertTypeForMem(QualType T);