================
@@ -3589,6 +3589,50 @@ static bool 
canEmitSpuriousReferenceToVariable(CodeGenFunction &CGF,
   }
 }
 
+/// Emit an LValue for a structured binding captured in an OpenMP region.
+/// Handles extracting individual bindings from the captured decomposed
+/// declaration (struct fields, array elements, etc.).
+LValue CodeGenFunction::EmitOMPCapturedBindingLValue(const BindingDecl *BD) {
+  assert(CapturedStmtInfo &&
+         CapturedStmtInfo->getKind() == CapturedRegionKind::CR_OpenMP &&
+         CGM.getLangOpts().OpenMP);
+  auto *DD = cast<VarDecl>(BD->getDecomposedDecl());
+  QualType AggregType = DD->getType();
+  if (AggregType->isReferenceType())
+    AggregType = AggregType->getPointeeType();
+  DeclarationNameInfo NameInfo(DD->getDeclName(), SourceLocation());
+  DeclRefExpr *DRE = DeclRefExpr::Create(
+      getContext(), NestedNameSpecifierLoc(), SourceLocation(), DD,
+      /*RefersToEnclosingVariableOrCapture=*/true, NameInfo, AggregType,
+      VK_LValue);
+  LValue CapLVal = EmitLValue(DRE);
----------------
alexey-bataev wrote:

Manually constructing a `DeclRefExpr` just to call `EmitLValue` is awkward. The 
regular `VarDecl` path in `EmitDeclRefLValue` (lines 3683-3720) handles all of: 
`LocalDeclMap` lookup, reference-type unwrapping via 
`EmitLoadOfReferenceLValue`, fall-back to `CapturedStmtInfo->lookup`, and the 
nontemporal annotation via `CGM.getOpenMPRuntime().isNontemporalDecl(VD)`. This 
new function reimplements only part of that and silently loses the nontemporal 
handling, which matters in `simd` regions. Either reuse the existing path (e.g. 
by emitting a synthetic DRE that goes through the standard `VarDecl` branch and 
then GEP the field), or make this function feature-equivalent.

https://github.com/llvm/llvm-project/pull/190832
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to