From 0490f64259f477c6926dffbc6fe3df6f3f08ef60 Mon Sep 17 00:00:00 2001 From: baojingjing Date: Tue, 17 Jun 2025 18:02:20 +0800 Subject: [PATCH 1/2] [PAC] [mangling] Fix an issue where definition mangle name is inconsistent with the declaration Signed-off-by:baojingjing --- clang/lib/AST/ItaniumMangle.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp index e3f91d6624b9..74aa70003068 100644 --- a/clang/lib/AST/ItaniumMangle.cpp +++ b/clang/lib/AST/ItaniumMangle.cpp @@ -1499,9 +1499,7 @@ void CXXNameMangler::mangleUnqualifiedName( { if (const CXXRecordDecl *A = dyn_cast(GD.getDecl())) { - // todo: if class info is signed, then we must mangle also the name of non polymorphic classes. - isPac = langOptions.PointerAuthMangleClass - && (!A->hasDefinition() || A->isPolymorphic()) && !A->isNoPac(); + isPac = langOptions.PointerAuthMangleClass && !A->isNoPac(); } } if (pauth_func) -- Gitee From 50d9086acf3d12ad7fef4b6fcb99e6532174074c Mon Sep 17 00:00:00 2001 From: baojingjing Date: Wed, 25 Jun 2025 10:08:13 +0800 Subject: [PATCH 2/2] [PAC] [hintonly] pauth-hint-only use instruction in nop space Signed-off-by:baojingjing --- llvm/lib/Target/AArch64/AArch64ISelLowering.cpp | 2 +- llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp index 40d6198b3f21..86c1b4f62746 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -11242,7 +11242,7 @@ SDValue AArch64TargetLowering::LowerRETURNADDR(SDValue Op, // Armv8.3-A architectures. On Armv8.3-A and onwards XPACI is available so use // that instead. SDNode *St; - if (Subtarget->hasPAuth()) { + if (Subtarget->hasPAuth() && !Subtarget->hasPAuthHintOnly()) { St = DAG.getMachineNode(AArch64::XPACI, DL, VT, ReturnAddress); } else { // XPACLRI operates on LR therefore we must move the operand accordingly. diff --git a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp index 500c1d8f3ab8..8375c59421bd 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp @@ -6636,7 +6636,7 @@ bool AArch64InstructionSelector::selectIntrinsic(MachineInstr &I, MF, TII, AArch64::LR, AArch64::GPR64RegClass, I.getDebugLoc()); } - if (STI.hasPAuth()) { + if (STI.hasPAuth() && !STI.hasPAuthHintOnly()) { MIB.buildInstr(AArch64::XPACI, {DstReg}, {MFReturnAddr}); } else { MIB.buildCopy({Register(AArch64::LR)}, {MFReturnAddr}); @@ -6663,7 +6663,7 @@ bool AArch64InstructionSelector::selectIntrinsic(MachineInstr &I, else { MFI.setReturnAddressIsTaken(true); - if (STI.hasPAuth()) { + if (STI.hasPAuth() && !STI.hasPAuthHintOnly()) { Register TmpReg = MRI.createVirtualRegister(&AArch64::GPR64RegClass); MIB.buildInstr(AArch64::LDRXui, {TmpReg}, {FrameAddr}).addImm(1); MIB.buildInstr(AArch64::XPACI, {DstReg}, {TmpReg}); -- Gitee