[PATCH] D79921: [OpenMP] Fix omp and clang pragmas

ISHIGURO, Hiroshi via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 14 04:15:34 PDT 2020


hishiguro updated this revision to Diff 263964.
hishiguro added a comment.

Fix clang-format error.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79921

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp


Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===================================================================
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -1730,9 +1730,22 @@
   auto CondBlock = createBasicBlock("omp.inner.for.cond");
   EmitBlock(CondBlock);
   const SourceRange R = S.getSourceRange();
-  LoopStack.push(CondBlock, SourceLocToDebugLoc(R.getBegin()),
-                 SourceLocToDebugLoc(R.getEnd()));
 
+  // If attributes are attached, push to the basic block with them.
+  const AttributedStmt *AS = nullptr;
+  if (auto *OMPD = dyn_cast<OMPParallelForDirective>(&S)) {
+    const CapturedStmt *CS = OMPD->getCapturedStmt(OMPD_parallel);
+    const Stmt *SS = CS->getCapturedStmt();
+    AS = dyn_cast_or_null<AttributedStmt>(SS);
+  }
+  if (AS)
+    LoopStack.push(CondBlock, CGM.getContext(), CGM.getCodeGenOpts(),
+                   AS->getAttrs(), SourceLocToDebugLoc(R.getBegin()),
+                   SourceLocToDebugLoc(R.getEnd()));
+  else
+    LoopStack.push(CondBlock, SourceLocToDebugLoc(R.getBegin()),
+                   SourceLocToDebugLoc(R.getEnd()));
+
   // If there are any cleanups between here and the loop-exit scope,
   // create a block to stage a loop exit along.
   llvm::BasicBlock *ExitBlock = LoopExit.getBlock();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79921.263964.patch
Type: text/x-patch
Size: 1304 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200514/2e917462/attachment.bin>


More information about the cfe-commits mailing list