[PATCH] D98980: [CodeGen] Don't crash on for loops with cond variables and no increment

2021-03-19 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Yes, LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98980/new/

https://reviews.llvm.org/D98980

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98980: [CodeGen] Don't crash on for loops with cond variables and no increment

2021-03-19 Thread Benjamin Kramer via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG19d2c65ddd75: [CodeGen] Dont crash on for loops with 
cond variables and no increment (authored by bkramer).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98980/new/

https://reviews.llvm.org/D98980

Files:
  clang/lib/CodeGen/CGStmt.cpp
  clang/test/CodeGenCXX/for-cond-var.cpp


Index: clang/test/CodeGenCXX/for-cond-var.cpp
===
--- clang/test/CodeGenCXX/for-cond-var.cpp
+++ clang/test/CodeGenCXX/for-cond-var.cpp
@@ -123,3 +123,16 @@
   // 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;
+}
Index: clang/lib/CodeGen/CGStmt.cpp
===
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -992,7 +992,7 @@
 
   // 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;
 }
 


Index: clang/test/CodeGenCXX/for-cond-var.cpp
===
--- clang/test/CodeGenCXX/for-cond-var.cpp
+++ clang/test/CodeGenCXX/for-cond-var.cpp
@@ -123,3 +123,16 @@
   // 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;
+}
Index: clang/lib/CodeGen/CGStmt.cpp
===
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -992,7 +992,7 @@
 
   // 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;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98980: [CodeGen] Don't crash on for loops with cond variables and no increment

2021-03-19 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer added a comment.

Landing this as it's a pretty bad crasher. Feel free to point out all my 
mistakes in post-commit review :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98980/new/

https://reviews.llvm.org/D98980

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98980: [CodeGen] Don't crash on for loops with cond variables and no increment

2021-03-19 Thread Jordan Rupprecht via Phabricator via cfe-commits
rupprecht accepted this revision.
rupprecht added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98980/new/

https://reviews.llvm.org/D98980

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98980: [CodeGen] Don't crash on for loops with cond variables and no increment

2021-03-19 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer created this revision.
bkramer added reviewers: rupprecht, rjmccall, rsmith.
bkramer requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This looks like an oversight from a875721d8a2d 
, creating 
IR that refers
to `for.inc` even if it doesn't exist.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98980

Files:
  clang/lib/CodeGen/CGStmt.cpp
  clang/test/CodeGenCXX/for-cond-var.cpp


Index: clang/test/CodeGenCXX/for-cond-var.cpp
===
--- clang/test/CodeGenCXX/for-cond-var.cpp
+++ clang/test/CodeGenCXX/for-cond-var.cpp
@@ -123,3 +123,16 @@
   // 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;
+}
Index: clang/lib/CodeGen/CGStmt.cpp
===
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -992,7 +992,7 @@
 
   // 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;
 }
 


Index: clang/test/CodeGenCXX/for-cond-var.cpp
===
--- clang/test/CodeGenCXX/for-cond-var.cpp
+++ clang/test/CodeGenCXX/for-cond-var.cpp
@@ -123,3 +123,16 @@
   // 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;
+}
Index: clang/lib/CodeGen/CGStmt.cpp
===
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -992,7 +992,7 @@
 
   // 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;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits