================
@@ -1310,21 +1310,92 @@ static llvm::Value
*CoerceIntOrPtrToIntOrPtr(llvm::Value *Val, llvm::Type *Ty,
return Val;
}
+static std::vector<PFPField> findPFPCoercedFields(CodeGenFunction &CGF,
+ QualType SrcFETy) {
+ // Coercion directly through memory does not work if the structure has
pointer
+ // field protection because the struct in registers has a different bit
+ // pattern to the struct in memory, so we must read the elements one by one
+ // and use them to form the coerced structure.
+ std::vector<PFPField> PFPFields;
+ CGF.getContext().findPFPFields(SrcFETy, CharUnits::Zero(), PFPFields,
+ /*IncludeVBases=*/true);
+
+ // Because we don't know which union member is selected, we don't modify the
+ // in-memory representation when passing a pointer that is part of a union
+ // field. This requires the union member to be trivially copyable;
+ // non-trivially-copyable unions cannot be directly passed by value.
+ llvm::erase_if(PFPFields, [](PFPField F) { return F.isWithinUnion; });
+ return PFPFields;
+}
+
+static llvm::Value *CreatePFPCoercedLoad(Address Src, QualType SrcFETy,
+ llvm::Type *Ty, CodeGenFunction &CGF)
{
+ std::vector<PFPField> PFPFields = findPFPCoercedFields(CGF, SrcFETy);
----------------
fmayer wrote:
maybe let's use a different name? Throughout this change, `PFPFields` is for
the result of `findPFPFields`
https://github.com/llvm/llvm-project/pull/172119
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits