[CodeGen] Don't crash on for loops with cond variables and no increment
This looks like an oversight from a875721d8a
, creating IR that refers
to `for.inc` even if it doesn't exist.
Differential Revision: https://reviews.llvm.org/D98980
This commit is contained in:
parent
9d081a7ffe
commit
19d2c65ddd
|
@ -992,7 +992,7 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S,
|
|||
|
||||
// We have entered the condition variable's scope, so we're now able to
|
||||
// jump to the continue block.
|
||||
Continue = getJumpDestInCurrentScope("for.inc");
|
||||
Continue = S.getInc() ? getJumpDestInCurrentScope("for.inc") : CondDest;
|
||||
BreakContinueStack.back().ContinueBlock = Continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -123,3 +123,16 @@ void PR49585_break() {
|
|||
// CHECK [[for_end]]:
|
||||
// CHECK: ret void
|
||||
}
|
||||
|
||||
// CHECK: define {{.*}} void @_Z16incless_for_loopv(
|
||||
void incless_for_loop() {
|
||||
// CHECK: br label %[[for_cond:.*]]
|
||||
// CHECK: [[for_cond]]:
|
||||
// CHECK: br i1 {{.*}}, label %[[for_body:.*]], label %[[for_end:.*]]
|
||||
// CHECK: [[for_body]]:
|
||||
// CHECK: br label %[[for_cond]]
|
||||
// CHECK: [[for_end]]:
|
||||
// CHECK: ret void
|
||||
// CHECK: }
|
||||
for (; int b = 0;) continue;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue