[PATCH] D136998: Try to implement lambdas with inalloca parameters by inlining the call operator function.

Reid Kleckner via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 2 15:00:41 PDT 2022


rnk added inline comments.


================
Comment at: clang/lib/CodeGen/CGClass.cpp:3064
+    if (I.getName().equals("this")) {
+      VMap[&I] = llvm::PoisonValue::get(I.getType());
+    } else {
----------------
Let's use getNullValue instead, just to avoid any complications for msan or ubsan, which may check for defined-ness.


================
Comment at: clang/lib/CodeGen/CodeGenModule.cpp:3588
         ABI->emitCXXStructor(GD);
+      // Hack for lambda forwarding calls with inalloca parameters.
+      else if (isa<CXXMethodDecl>(FD) && cast<CXXMethodDecl>(FD)->isLambdaStaticInvoker() &&
----------------
Can you move most of the details of this out of line to try to keep this as high level as possible?


================
Comment at: clang/lib/CodeGen/CodeGenModule.cpp:3590-3593
+          getTarget().getCXXABI().isMicrosoft() &&
+          llvm::any_of(cast<CXXMethodDecl>(FD)->parameters(), [&](ParmVarDecl *P) {
+            return isInAllocaArgument(getCXXABI(), P->getType());
+            })) {
----------------
For simplicity, what if we always emitted the call operator for all lambda static invokers into the IR first? So, this logic would then become almost exactly the same as the emitCXXStructor logic above.

Later, in EmitLambdaStaticInvokeBody, we can detect the inalloca case and start the cloning.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136998



More information about the cfe-commits mailing list