aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGStmt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen/CGStmt.cpp')
-rw-r--r--clang/lib/CodeGen/CGStmt.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 031ef73..9d19cdb 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -858,21 +858,17 @@ void CodeGenFunction::EmitIndirectGotoStmt(const IndirectGotoStmt &S) {
return;
}
- // Ensure that we have an i8* for our PHI node.
+ // Ensure that we have an i8* for the indirect branch.
llvm::Value *V = Builder.CreateBitCast(EmitScalarExpr(S.getTarget()),
Int8PtrTy, "addr");
- llvm::BasicBlock *CurBB = Builder.GetInsertBlock();
-
- // Get the basic block for the indirect goto.
- llvm::BasicBlock *IndGotoBB = GetIndirectGotoBlock();
- // The first instruction in the block has to be the PHI for the switch dest,
- // add an entry for this branch.
- cast<llvm::PHINode>(IndGotoBB->begin())->addIncoming(V, CurBB);
+ // Create a new indirect branch instruction for this statement
+ llvm::IndirectBrInst *IndBr = Builder.CreateIndirectBr(V);
- EmitBranch(IndGotoBB);
- if (CurBB && CurBB->getTerminator())
- addInstToCurrentSourceAtom(CurBB->getTerminator(), nullptr);
+ // Add all address-taken labels as possible destinations
+ for (llvm::BasicBlock *BB : AddressTakenLabels) {
+ IndBr->addDestination(BB);
+ }
}
void CodeGenFunction::EmitIfStmt(const IfStmt &S) {