[llvm-dev] Using !dereferenceable metadata on the result of llvm.read_register?

Johnson, Nicholas Paul via llvm-dev llvm-dev at lists.llvm.org
Mon May 8 07:54:20 PDT 2017


Hey all,

On my architecture, a certain important base pointer is stored in a physical register.  In the IR, code accesses this pointer via an llvm.read_register.i32 intrinsic.  I would like to encode the information that this pointer is dereferenceable so that LICM can speculatively hoist loads derived from that base pointer.  Specifically, I want llvm::isDereferenceableAndAlignedPointer() to return true on such pointers, which will cause llvm::isSafeToSpeculativelyExecute() to return true when loading from such pointers.

LLVM features Attribute::Dereferenceable for pointer-valued arguments or return values, or !dereferenceable metadata for pointer-typed results of load instructions.  The problem is that llvm.read_register.i32/.i64 return integer values, so they cannot accept Attribute::Dereferenceable.  I don't think there is any good way to encode this dereferenceability.

I would appreciate any suggestions.  Perhaps the spec could be relaxed to allow !dereferenceable metadata on inttoptr instructions...

Thank you,
Nick Johnson
D. E. Shaw Research




More information about the llvm-dev mailing list