[PATCH] D153883: [Clang][OpenMP] Delay emission of __kmpc_alloc_shared for escaped VLAs

Alexey Bataev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 5 14:14:48 PDT 2023


ABataev added inline comments.


================
Comment at: clang/lib/CodeGen/CGDecl.cpp:591
+      auto &RT =
+          *(static_cast<CGOpenMPRuntimeGPU *>(&CGF.CGM.getOpenMPRuntime()));
+      RT.getKmpcFreeShared(CGF, AddrSizePair);
----------------
Same, just CGOpenMPRuntime &RT = CGM.getOpenMPRuntime();


================
Comment at: clang/lib/CodeGen/CGDecl.cpp:1605
+    if (getLangOpts().OpenMPIsDevice) {
+      auto &RT = static_cast<CGOpenMPRuntimeGPU &>(CGM.getOpenMPRuntime());
+      if (RT.isDelayedVariableLengthDecl(*this, &D)) {
----------------
Here and in other places, jusy remove the cast to CGOpenMPRuntimeGPU, CGM.getOpenMPRuntime() already provides virtual functions, use them directly without cast:
```
CGOpenMPRuntime &RT = CGM.getOpenMPRuntime();
```


================
Comment at: clang/lib/CodeGen/CGOpenMPRuntime.h:699-710
+  /// Get call to __kmpc_alloc_shared
+  virtual std::pair<llvm::Value *, llvm::Value *>
+  getKmpcAllocShared(CodeGenFunction &CGF, const VarDecl *VD) {
+    llvm_unreachable("not implemented");
+  }
+
+  /// Get call to __kmpc_free_shared
----------------
doru1004 wrote:
> @ABataev I have added the interface entries here.
Then you already good, just do not gast to CGOpenMPRuntimeGPU, use CGM.getOpenMPRuntime() directly since it already has these member functions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153883



More information about the cfe-commits mailing list