[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:08:40 PDT 2023


ABataev added inline comments.


================
Comment at: clang/lib/CodeGen/CGDecl.cpp:1606
+      CGOpenMPRuntimeGPU &RT =
+          *(static_cast<CGOpenMPRuntimeGPU *>(&CGM.getOpenMPRuntime()));
+      if (RT.isDelayedVariableLengthDecl(*this, &D)) {
----------------
doru1004 wrote:
> ABataev wrote:
> > ABataev wrote:
> > > 1. use `static_cast<CGOpenMPRuntimeGPU &>(CGM.getOpenMPRuntime())`
> > > 2. It will crash if your device is not GPU. Better to make `getKmpcAllocShared` and `getKmpcFreeShared` virtual (just like `isDelayedVariableLengthDecl`) in base CGOpenMPRuntime, since it may be required not only for GPU-based devices.
> > Check the second item, please, better to make all new member function virtual and handle it for non-GPU devices too
> The support I am adding is only meant for GPUs. I am not sure why we need to consider non-GPUs. There already exists a VLA handling for non-GPUs and that one should be used.
1. It will crash the compiler if your device is not a GPU (say, CPU).
2. I'm not asking to implement it for non-GPU, I'm asking to provide common interface. The general implementation should call just llvm_unreachable, nothing else.


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