[PATCH] D70258: [OpenMP][IR-Builder] Introduce the finalization stack

Alexey Bataev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 14 11:30:06 PST 2019


ABataev added inline comments.


================
Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:1483
+    // OpenMPIRBuilder is asked to construct a parallel (or similar) construct.
+    auto FiniCB = [&](llvm::OpenMPIRBuilder::InsertPointTy IP) {
+      assert(IP.getBlock()->end() == IP.getPoint() &&
----------------
Better to not capture all the object implicitly by reference, provide explicit list


================
Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:1486
+             "Clang CG should cause non-terminated block!");
+      auto OldIP = CGF.Builder.saveIP();
+      CGF.Builder.restoreIP(IP);
----------------
Use `InsertPointGuard` where possible rather than use `saveIP/restoreIP` explicitly


================
Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:1490
+          CGF.getOMPCancelDestination(OMPD_parallel);
+      assert(Dest.getBlock());
+      CGF.EmitBranchThroughCleanup(Dest);
----------------
Add a message for the assert.


================
Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:1499-1509
+    OMPBuilder->pushFinalizationCB(std::move(FI));
+  }
+
   CGOpenMPOutlinedRegionInfo CGInfo(*CS, ThreadIDVar, CodeGen, InnermostKind,
                                     HasCancel, OutlinedHelperName);
   CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, &CGInfo);
+  llvm::Function *Fn = CGF.GenerateOpenMPCapturedStmtFunction(*CS);
----------------
Again, need RAII


================
Comment at: llvm/include/llvm/Frontend/OpenMPIRBuilder.h:69-71
+  void pushFinalizationCB(FinalizationInfo &&FI) {
+    FinalizationStack.emplace_back(std::move(FI));
+  }
----------------
Maybe `push...` for const reference and `emplace...` for variadic template (just like in standard library)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70258





More information about the cfe-commits mailing list