[PATCH] [OPENMP] Fixed codegen for 'schedule' clause with non-constant chunk size.

John McCall rjmccall at gmail.com
Thu May 21 00:06:28 PDT 2015


Mostly seems fine, but using a global variable is problematic.


================
Comment at: lib/CodeGen/CGStmtOpenMP.cpp:980
@@ +979,3 @@
+    CGF.Builder.CreateAlignedStore(Chunk, LoopChunk, Alignment);
+    return LoopChunk;
+  }
----------------
Using a global variable here makes this non-reentrant.  Unless there's some weird restriction on where this clause can appear, that's not okay.

You might have to capture this value in the CapturedStmt.  That should just be a matter of making an artificial VarDecl, initializing it to the captured value, and capturing it.  If you can capture it by value instead of by reference, that would be slightly preferable.

================
Comment at: lib/CodeGen/CGStmtOpenMP.cpp:1052
@@ -1020,5 +1051,3 @@
         ScheduleKind = C->getScheduleKind();
-        if (auto Ch = C->getChunkSize()) {
-          Chunk = EmitScalarExpr(Ch);
-          Chunk = EmitScalarConversion(Chunk, Ch->getType(),
-                                       S.getIterationVariable()->getType());
+        if (Chunk && Chunk->getType()->isPointerTy()) {
+          Chunk = Builder.CreateAlignedLoad(
----------------
Please test for a global value instead of checking the type.

http://reviews.llvm.org/D9606

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list