]> granicus.if.org Git - clang/commitdiff
Add CodeGenFunction::EmitDummyBlock for marking places where we make
authorDaniel Dunbar <daniel@zuster.org>
Tue, 11 Nov 2008 04:34:23 +0000 (04:34 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 11 Nov 2008 04:34:23 +0000 (04:34 +0000)
"dummy" blocks (blocks just used to make sure we have a place to dump
code to).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59022 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGObjCMac.cpp
lib/CodeGen/CGStmt.cpp
lib/CodeGen/CodeGenFunction.h

index 34f9952252858641fdd81c15e6da9055eac84573..903e92dfc2df8377ecea1c2016117bd45895e627 100644 (file)
@@ -1717,7 +1717,7 @@ void CGObjCMac::EmitThrowStmt(CodeGen::CodeGenFunction &CGF,
   
   CGF.Builder.CreateCall(ObjCTypes.ExceptionThrowFn, ExceptionAsObject);
   CGF.Builder.CreateUnreachable();
-  CGF.EmitBlock(CGF.createBasicBlock("bb"));
+  CGF.EmitDummyBlock();
 }
 
 void CodeGenFunction::EmitJumpThroughFinally(ObjCEHEntry *E,
index 9d6a79b5842986fba1cce90528fd22da4ea2e646..82c39208a42a85968dcc4d78a63a3aa38ee4bd45 100644 (file)
@@ -167,6 +167,10 @@ void CodeGenFunction::EmitBlock(llvm::BasicBlock *BB) {
   Builder.SetInsertPoint(BB);
 }
 
+void CodeGenFunction::EmitDummyBlock() {
+  EmitBlock(createBasicBlock());
+}
+
 void CodeGenFunction::EmitLabel(const LabelStmt &S) {
   llvm::BasicBlock *NextBB = getBasicBlockForLabel(&S);
   EmitBlock(NextBB);
@@ -189,7 +193,7 @@ void CodeGenFunction::EmitGotoStmt(const GotoStmt &S) {
   
   // Emit a block after the branch so that dead code after a goto has some place
   // to go.
-  Builder.SetInsertPoint(createBasicBlock("", CurFn));
+  EmitDummyBlock();
 }
 
 void CodeGenFunction::EmitIndirectGotoStmt(const IndirectGotoStmt &S) {
@@ -210,7 +214,7 @@ void CodeGenFunction::EmitIndirectGotoStmt(const IndirectGotoStmt &S) {
 
   // Emit a block after the branch so that dead code after a goto has some place
   // to go.
-  Builder.SetInsertPoint(createBasicBlock("", CurFn));
+  EmitDummyBlock();
 }
 
 void CodeGenFunction::EmitIfStmt(const IfStmt &S) {
@@ -433,7 +437,7 @@ void CodeGenFunction::EmitReturnOfRValue(RValue RV, QualType Ty) {
 
   // Emit a block after the branch so that dead code after a return has some
   // place to go.
-  EmitBlock(createBasicBlock());
+  EmitDummyBlock();
 }
 
 /// EmitReturnStmt - Note that due to GCC extensions, this can have an operand
@@ -473,7 +477,7 @@ void CodeGenFunction::EmitReturnStmt(const ReturnStmt &S) {
   
   // Emit a block after the branch so that dead code after a return has some
   // place to go.
-  EmitBlock(createBasicBlock());
+  EmitDummyBlock();
 }
 
 void CodeGenFunction::EmitDeclStmt(const DeclStmt &S) {
@@ -487,7 +491,7 @@ void CodeGenFunction::EmitBreakStmt() {
 
   llvm::BasicBlock *Block = BreakContinueStack.back().BreakBlock;
   Builder.CreateBr(Block);
-  EmitBlock(createBasicBlock());
+  EmitDummyBlock();
 }
 
 void CodeGenFunction::EmitContinueStmt() {
@@ -495,7 +499,7 @@ void CodeGenFunction::EmitContinueStmt() {
 
   llvm::BasicBlock *Block = BreakContinueStack.back().ContinueBlock;
   Builder.CreateBr(Block);
-  EmitBlock(createBasicBlock());
+  EmitDummyBlock();
 }
 
 /// EmitCaseStmtRange - If case statement range is not too big then
index c9dcaa7d5502cbf3bf6339c1f9760acb210fe09d..a454cece405312f404fea5798a2b4f3611ca465d 100644 (file)
@@ -225,6 +225,11 @@ public:
   llvm::BasicBlock *getBasicBlockForLabel(const LabelStmt *S);
   
   void EmitBlock(llvm::BasicBlock *BB);
+
+  /// EmitDummyBlock - Emit a new block which will never be branched
+  /// to. This is used to satisfy the invariant that codegen always
+  /// has an active unterminated block to dump code into.
+  void EmitDummyBlock();
   
   /// ErrorUnsupported - Print out an error that codegen doesn't support the
   /// specified stmt yet.