ekatz updated this revision to Diff 257482.
ekatz added a comment.

Use the old structure of the algorithm, with the fix, as requested.


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

https://reviews.llvm.org/D78098

Files:
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/test/CodeGen/atomic-struct-bug.cpp


Index: clang/test/CodeGen/atomic-struct-bug.cpp
===================================================================
--- /dev/null
+++ clang/test/CodeGen/atomic-struct-bug.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+// PR45476
+
+// This test used to get into an infinite loop,
+// which, in turn, caused clang to never finish execution.
+
+struct s3 {
+  char a, b, c;
+};
+
+_Atomic struct s3 a;
+
+extern "C" void foo() {
+  // CHECK-LABEL: @foo
+  // CHECK: store atomic i32
+
+  a = s3{1, 2, 3};
+}
+
Index: clang/lib/CodeGen/CGExprAgg.cpp
===================================================================
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -683,8 +683,10 @@
     if (CastExpr *castE = dyn_cast<CastExpr>(op)) {
       if (castE->getCastKind() == kind)
         return castE->getSubExpr();
-      if (castE->getCastKind() == CK_NoOp)
+      if (castE->getCastKind() == CK_NoOp) {
+        op = castE->getSubExpr();
         continue;
+      }
     }
     return nullptr;
   }


Index: clang/test/CodeGen/atomic-struct-bug.cpp
===================================================================
--- /dev/null
+++ clang/test/CodeGen/atomic-struct-bug.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+// PR45476
+
+// This test used to get into an infinite loop,
+// which, in turn, caused clang to never finish execution.
+
+struct s3 {
+  char a, b, c;
+};
+
+_Atomic struct s3 a;
+
+extern "C" void foo() {
+  // CHECK-LABEL: @foo
+  // CHECK: store atomic i32
+
+  a = s3{1, 2, 3};
+}
+
Index: clang/lib/CodeGen/CGExprAgg.cpp
===================================================================
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -683,8 +683,10 @@
     if (CastExpr *castE = dyn_cast<CastExpr>(op)) {
       if (castE->getCastKind() == kind)
         return castE->getSubExpr();
-      if (castE->getCastKind() == CK_NoOp)
+      if (castE->getCastKind() == CK_NoOp) {
+        op = castE->getSubExpr();
         continue;
+      }
     }
     return nullptr;
   }
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to