================
@@ -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);
+ QualType CanonType = AggregType.getCanonicalType();
+ llvm::Type *StructTy = CGM.getTypes().ConvertTypeForMem(CanonType);
+ Address Addr = CapLVal.getAddress();
+ if (Addr.getElementType() != StructTy) {
+ Addr = Addr.withElementType(StructTy);
+ CapLVal = MakeAddrLValue(Addr, CanonType, CapLVal.getBaseInfo(),
+ CapLVal.getTBAAInfo());
+ }
----------------
alexey-bataev wrote:
The element-type fixup with `withElementType(StructTy)` is a smell. If
`EmitLValue(DRE)` returns an address whose element type does not match the
canonical type of the DRE, that points at a problem in the DRE construction or
in the OpenMP capture path, not something to paper over here. With opaque
pointers the element type carries no semantic meaning at the IR level, so this
only matters for some assertion/debug consumer. Investigate why it ever differs
and fix the root cause; otherwise drop the fixup.
https://github.com/llvm/llvm-project/pull/190832
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits