diff gen/llvmhelpers.cpp @ 353:a7a26f538d6e trunk

[svn r374] Move label target basic block from AST to IRFunction. This is a first step to allowing labels to be emitted multiple times. (for instance within finally blocks)
author ChristianK
date Mon, 14 Jul 2008 11:07:15 +0200
parents 385a18242485
children d8357f7004ca
line wrap: on
line diff
--- a/gen/llvmhelpers.cpp	Mon Jul 14 10:01:09 2008 +0200
+++ b/gen/llvmhelpers.cpp	Mon Jul 14 11:07:15 2008 +0200
@@ -186,8 +186,11 @@
     if(lblstmt->asmLabel)
         error("cannot goto into inline asm block", loc->toChars());
 
-    if (lblstmt->llvmBB == NULL)
-        lblstmt->llvmBB = llvm::BasicBlock::Create("label", gIR->topfunc());
+    // find target basic block
+    std::string labelname = target->toChars();
+    llvm::BasicBlock*& targetBB = gIR->func()->labelToBB[labelname];
+    if (targetBB == NULL)
+        targetBB = llvm::BasicBlock::Create("label", gIR->topfunc());
 
     // find finallys between goto and label
     EnclosingHandler* endfinally = enclosinghandler;
@@ -202,7 +205,7 @@
     // emit code for finallys between goto and label
     DtoEnclosingHandlers(enclosinghandler, endfinally);
 
-    llvm::BranchInst::Create(lblstmt->llvmBB, gIR->scopebb());
+    llvm::BranchInst::Create(targetBB, gIR->scopebb());
 }
 
 /****************************************************************************************/