[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:45 PST 2026
================
@@ -2232,6 +2233,45 @@ static void emitNonZeroVLAInit(CodeGenFunction &CGF, QualType baseType,
CGF.EmitBlock(contBB);
}
+Address CodeGenFunction::EmitAddressOfPFPField(Address RecordPtr,
+ const PFPField &Field) {
+ return EmitAddressOfPFPField(
+ RecordPtr,
+ Builder.CreateConstInBoundsByteGEP(RecordPtr.withElementType(Int8Ty),
+ Field.offset),
+ Field.field);
+}
+
+Address CodeGenFunction::EmitAddressOfPFPField(Address RecordPtr,
+ Address PtrPtr,
+ const FieldDecl *Field) {
+ llvm::Value *Disc;
+ bool IsPAuthSupported = getContext().getTargetInfo().getTriple().getArch() ==
+ llvm::Triple::aarch64;
+ if (!IsPAuthSupported ||
+ CGM.getContext().arePFPFieldsTriviallyCopyable(Field->getParent())) {
+ uint64_t FieldSignature =
+ llvm::getPointerAuthStableSipHash(CGM.getPFPFieldName(Field));
+ if (!IsPAuthSupported)
+ FieldSignature &= 0xff;
+ Disc = llvm::ConstantInt::get(CGM.Int64Ty, FieldSignature);
+ } else {
----------------
ojhunt wrote:
brace nit
https://github.com/llvm/llvm-project/pull/172119
More information about the llvm-branch-commits
mailing list