diff options
Diffstat (limited to 'clang/lib/CodeGen/CGStmt.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGStmt.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp index d30781f22f0..573973a9821 100644 --- a/clang/lib/CodeGen/CGStmt.cpp +++ b/clang/lib/CodeGen/CGStmt.cpp @@ -76,7 +76,6 @@ void CodeGenFunction::EmitStmt(const Stmt *S) { case Stmt::SEHExceptStmtClass: case Stmt::SEHFinallyStmtClass: case Stmt::MSDependentExistsStmtClass: - case Stmt::OMPSimdDirectiveClass: llvm_unreachable("invalid statement class to emit generically"); case Stmt::NullStmtClass: case Stmt::CompoundStmtClass: @@ -176,6 +175,9 @@ void CodeGenFunction::EmitStmt(const Stmt *S) { case Stmt::OMPParallelDirectiveClass: EmitOMPParallelDirective(cast<OMPParallelDirective>(*S)); break; + case Stmt::OMPSimdDirectiveClass: + EmitOMPSimdDirective(cast<OMPSimdDirective>(*S)); + break; } } @@ -510,6 +512,8 @@ void CodeGenFunction::EmitWhileStmt(const WhileStmt &S) { JumpDest LoopHeader = getJumpDestInCurrentScope("while.cond"); EmitBlock(LoopHeader.getBlock()); + LoopStack.push(LoopHeader.getBlock()); + // Create an exit block for when the condition fails, which will // also become the break target. JumpDest LoopExit = getJumpDestInCurrentScope("while.end"); @@ -573,6 +577,8 @@ void CodeGenFunction::EmitWhileStmt(const WhileStmt &S) { // Branch to the loop header again. EmitBranch(LoopHeader.getBlock()); + LoopStack.pop(); + // Emit the exit block. EmitBlock(LoopExit.getBlock(), true); @@ -593,6 +599,9 @@ void CodeGenFunction::EmitDoStmt(const DoStmt &S) { // Emit the body of the loop. llvm::BasicBlock *LoopBody = createBasicBlock("do.body"); + + LoopStack.push(LoopBody); + EmitBlockWithFallThrough(LoopBody, Cnt); { RunCleanupsScope BodyScope(*this); @@ -623,6 +632,8 @@ void CodeGenFunction::EmitDoStmt(const DoStmt &S) { Builder.CreateCondBr(BoolCondVal, LoopBody, LoopExit.getBlock(), PGO.createLoopWeights(S.getCond(), Cnt)); + LoopStack.pop(); + // Emit the exit block. EmitBlock(LoopExit.getBlock()); @@ -654,6 +665,8 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S) { llvm::BasicBlock *CondBlock = Continue.getBlock(); EmitBlock(CondBlock); + LoopStack.push(CondBlock); + // If the for loop doesn't have an increment we can just use the // condition as the continue block. Otherwise we'll need to create // a block for it (in the current scope, i.e. in the scope of the @@ -724,6 +737,8 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S) { if (DI) DI->EmitLexicalBlockEnd(Builder, S.getSourceRange().getEnd()); + LoopStack.pop(); + // Emit the fall-through block. EmitBlock(LoopExit.getBlock(), true); } @@ -749,6 +764,8 @@ void CodeGenFunction::EmitCXXForRangeStmt(const CXXForRangeStmt &S) { llvm::BasicBlock *CondBlock = createBasicBlock("for.cond"); EmitBlock(CondBlock); + LoopStack.push(CondBlock); + // If there are any cleanups between here and the loop-exit scope, // create a block to stage a loop exit along. llvm::BasicBlock *ExitBlock = LoopExit.getBlock(); @@ -798,6 +815,8 @@ void CodeGenFunction::EmitCXXForRangeStmt(const CXXForRangeStmt &S) { if (DI) DI->EmitLexicalBlockEnd(Builder, S.getSourceRange().getEnd()); + LoopStack.pop(); + // Emit the fall-through block. EmitBlock(LoopExit.getBlock(), true); } |