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

Sanjoy Das via llvm-dev llvm-dev at lists.llvm.org
Mon May 8 08:06:17 PDT 2017


It is probably best to change llvm.read_register to return a pointer
depending on the mangling, after which you can tag the return value
with !dereferenceable.  There are other intrinsics in LLVM that also
return the "any" type, so this won't be truly new.

Another possibility is to allow !dereferenceable on integer types,
given how LLVM conflates integers and pointers (with the exception of
"non integral" pointers).

-- Sanjoy

On Mon, May 8, 2017 at 7:54 AM, Johnson, Nicholas Paul via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> 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
>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


More information about the llvm-dev mailing list