[llvm-branch-commits] [clang] [Clang] Add pointer field protection feature. (PR #133538)
Florian Mayer via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Dec 4 16:35:49 PST 2025
================
@@ -1310,21 +1310,91 @@ 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, true);
----------------
fmayer wrote:
`/*IsWithinUnion=*/true`
And I am confused, or `isWithinUnion` is true for all of the return objects? AFAIK in `findPFPFields` `IsWithinUnion` can only be changed to true (through the `|=`), and never to false. And all the recursive calls either use `isWithinUnion` or `true`.
https://github.com/llvm/llvm-project/pull/133538
More information about the llvm-branch-commits
mailing list