[clang] [clang][PAC] Support trivially_relocating polymorphic objects (PR #144420)
Corentin Jabot via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 17 20:37:16 PDT 2025
================
@@ -4467,17 +4467,25 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
case Builtin::BI__builtin_trivially_relocate:
case Builtin::BImemmove:
case Builtin::BI__builtin_memmove: {
+ QualType CopiedType = E->getArg(0)->getType()->getPointeeType();
Address Dest = EmitPointerWithAlignment(E->getArg(0));
Address Src = EmitPointerWithAlignment(E->getArg(1));
Value *SizeVal = EmitScalarExpr(E->getArg(2));
- if (BuiltinIDIfNoAsmLabel == Builtin::BI__builtin_trivially_relocate)
+ if (BuiltinIDIfNoAsmLabel == Builtin::BI__builtin_trivially_relocate) {
+ QualType BaseElementType = getContext().getBaseElementType(CopiedType);
+ if (getContext().containsAddressDiscriminatedPointerAuth(
+ BaseElementType)) {
+ llvm::Instruction *LastFixupInstruction =
+ EmitPointerAuthRelocationFixup(CopiedType, Dest, Src, SizeVal);
+ addInstToNewSourceAtom(LastFixupInstruction, nullptr);
----------------
cor3ntin wrote:
It's not really a fixup if it's doing the reallocation inside the fixup.
So either we need a better name, or we need to do it after the memmove line 4492
https://github.com/llvm/llvm-project/pull/144420
More information about the cfe-commits
mailing list