[OPENMP] Fix crash on loop control vars explicitly marked as private.
authorAlexey Bataev <a.bataev@hotmail.com>
Tue, 28 Apr 2015 13:20:05 +0000 (13:20 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Tue, 28 Apr 2015 13:20:05 +0000 (13:20 +0000)
It is allowed to mark loop control vars as private in 'private' or 'lastprivate' clause, so no need to assert here.

llvm-svn: 235985

clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/test/OpenMP/for_private_codegen.cpp

index e445e76..6a4b5ec 100644 (file)
@@ -578,15 +578,12 @@ static void EmitPrivateLoopCounters(CodeGenFunction &CGF,
                                     ArrayRef<Expr *> Counters) {
   for (auto *E : Counters) {
     auto VD = cast<VarDecl>(cast<DeclRefExpr>(E)->getDecl());
-    bool IsRegistered = LoopScope.addPrivate(VD, [&]() -> llvm::Value * {
+    (void)LoopScope.addPrivate(VD, [&]() -> llvm::Value *{
       // Emit var without initialization.
       auto VarEmission = CGF.EmitAutoVarAlloca(*VD);
       CGF.EmitAutoVarCleanups(VarEmission);
       return VarEmission.getAllocatedAddress();
     });
-    assert(IsRegistered && "counter already registered as private");
-    // Silence the warning about unused variable.
-    (void)IsRegistered;
   }
 }
 
index e87473b..f4d1834 100644 (file)
@@ -115,6 +115,12 @@ int main() {
     vec[i] = t_var;
     s_arr[i] = var;
   }
+  int i;
+#pragma omp parallel
+#pragma omp for private(i)
+  for (i = 0; i < 2; ++i) {
+    ;
+  }
   return tmain<int>();
 #endif
 }