[llvm-branch-commits] [clang] [Clang] Add pointer field protection feature. (PR #172119)

Oliver Hunt via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Jan 13 12:46:46 PST 2026


================
@@ -5627,15 +5754,25 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
         } else {
           uint64_t SrcSize = SrcTypeSize.getFixedValue();
           uint64_t DstSize = DstTypeSize.getFixedValue();
+          bool HasPFPFields = !findPFPCoercedFields(*this, I->Ty).empty();
 
           // If the source type is smaller than the destination type of the
           // coerce-to logic, copy the source value into a temp alloca the size
           // of the destination type to allow loading all of it. The bits past
           // the source value are left undef.
-          if (SrcSize < DstSize) {
+          if (HasPFPFields || SrcSize < DstSize) {
             Address TempAlloca = CreateTempAlloca(STy, Src.getAlignment(),
                                                   Src.getName() + ".coerce");
-            Builder.CreateMemCpy(TempAlloca, Src, SrcSize);
+            if (HasPFPFields) {
+              // Structures with PFP fields require a coerced load to remove any
+              // pointer signatures.
+              Builder.CreateStore(
+                  CreatePFPCoercedLoad(Src, I->Ty, ArgInfo.getCoerceToType(),
+                                       *this),
+                  TempAlloca);
+            } else {
----------------
ojhunt wrote:

nit no braces here

https://github.com/llvm/llvm-project/pull/172119


More information about the llvm-branch-commits mailing list