[clang] fd3cad7 - [clang] Fix ForStmt mustprogress handling

Atmn Patel via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 9 08:38:19 PST 2020


Author: Atmn Patel
Date: 2020-11-09T11:38:06-05:00
New Revision: fd3cad7a60168b49f7bc160354655d7605847d41

URL: https://github.com/llvm/llvm-project/commit/fd3cad7a60168b49f7bc160354655d7605847d41
DIFF: https://github.com/llvm/llvm-project/commit/fd3cad7a60168b49f7bc160354655d7605847d41.diff

LOG: [clang] Fix ForStmt mustprogress handling

D86841 had an error where for statements with no conditional were
required to make progress. This is not true, this patch removes that
line, and adds regression tests.

Differential Revision: https://reviews.llvm.org/D91075

Added: 
    

Modified: 
    clang/lib/CodeGen/CGStmt.cpp
    clang/test/CodeGen/attr-mustprogress-1.c
    clang/test/CodeGen/attr-mustprogress-1.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 972da3d4ea2d..d8be0ef4e525 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -947,7 +947,6 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S,
   Expr::EvalResult Result;
   if (LanguageRequiresProgress()) {
     if (!S.getCond()) {
-      LoopMustProgress = true;
       FnIsMustProgress = false;
     } else if (!S.getCond()->EvaluateAsInt(Result, getContext())) {
       LoopMustProgress = true;

diff  --git a/clang/test/CodeGen/attr-mustprogress-1.c b/clang/test/CodeGen/attr-mustprogress-1.c
index a5a8595218a1..2ff068b8b90a 100644
--- a/clang/test/CodeGen/attr-mustprogress-1.c
+++ b/clang/test/CodeGen/attr-mustprogress-1.c
@@ -7,6 +7,17 @@
 int a = 0;
 int b = 0;
 
+// CHECK: Function Attrs: noinline nounwind optnone
+// CHECK-LABEL: @f0(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:    br label [[FOR_COND:%.*]]
+// CHECK:       for.cond:
+// CHECK-NOT:    br label [[FOR_COND]], !llvm.loop !{{.*}}
+//
+void f0() {
+  for (; ;) ;
+}
+
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: @f1(
 // CHECK-NEXT:  entry:

diff  --git a/clang/test/CodeGen/attr-mustprogress-1.cpp b/clang/test/CodeGen/attr-mustprogress-1.cpp
index 6d53d2d1148d..945d74663c6d 100644
--- a/clang/test/CodeGen/attr-mustprogress-1.cpp
+++ b/clang/test/CodeGen/attr-mustprogress-1.cpp
@@ -7,6 +7,16 @@
 int a = 0;
 int b = 0;
 
+// CHECK: Function Attrs: noinline nounwind optnone
+// CHECK-LABEL: @_Z2f0v(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:    br label [[FOR_COND:%.*]]
+// CHECK:       for.cond:
+// CHECK-NOT:    br label [[FOR_COND]], !llvm.loop !{{.*}}
+void f0() {
+  for (; ;) ;
+}
+
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: @_Z2f1v(
 // CHECK-NEXT:  entry:


        


More information about the cfe-commits mailing list