[llvm-dev] RFC: ConstantPtrAuth for signed pointers on AArch64

Chris Lattner via llvm-dev llvm-dev at lists.llvm.org
Tue Dec 8 10:20:18 PST 2020


On Dec 8, 2020, at 4:30 AM, Tim Northover via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> To put signed pointers into global initializers (e.g. vtables) and other
> desirable features there needs to be a Constant that represents "sign this
> pointer in such and such way".

Cool.

> Shouldn't this be a ConstantExpr?
> ---------------------------------
> 
> There is one key interface for ConstantExpr we cannot currently support:
> getAsInstruction. When an address discriminator is present, the ptrauth constant
> represents an @llvm.ptrauth.blend followed by an @llvm.ptrauth.sign, two
> separate instructions.
> 
> Because of that I've so far implemented it as its own separate entity in the
> Constant hierarchy (kind of like blockaddress).
> 
> It might well be better to give up on intrinsic orthogonality and add one for
> this case though. It would simplify the changes to lib/IR etc.

I think that making this a ConstantExpr is the right way to go.

It looks like getAsInstruction is only called in two passes (GlobalOpt and ConstantHoisting) and the later one is only called on ConstantExpr casts.  I’d recommend reworking ConstantHoisting to not call this (instead just ask the cast opcode and make its own cast), and sink getAsInstruction into GlobalOpt as a static function.

-Chris


More information about the llvm-dev mailing list