[llvm] [Intrinsics] Add @llvm.dereferenceable intrinsic. (PR #120755)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 20 08:17:40 PST 2024


nikic wrote:

> > > Alternatively we could use an assume bundle with a dereferenceable attribute. But as a follow-up I would like to allow non-immediate size arguments, and this may not mesh well with the attribute.
> > 
> > 
> > I don't understand this bit. Using a non-immediate arguments for operand bundle assumes is generally okay.
> > I don't think we should introduce a new intrinsic if existing assume infrastructure covers it.
> 
> I assumed there might be an issue with customizing the logic to handle the attribute with immediate only in the function arg context and variable arguments in the assume context. But if that won't be an issue I'll do it that way, assuming the general idea seems good.

Variable arguments should already work (as in not break anything -- just be unused). We explicitly allow this in LangRef:

> While attributes expect constant arguments, assume operand bundles may be provided a dynamic value, for example:

-----

> Ah sorry, another advantage of using an intrinsic is that it is easier to find a dominating `@llvm.dereferenceable`; with an assume bundle, it would be more complicated (iterating over all users of the pointer and checking if any is an assume that dominates the point we want to get deref info for

Not sure what mechanism you have in mind here for llvm.dereferenceable. The assumes will be part of the AssumptionCache.

isDereferenceableAndAlignedPointer() already supports operand bundle assumes for dereferenceable, but I think it currently has a weird implementation quirk where you also need to have an aligned bundle on the same assume.

https://github.com/llvm/llvm-project/pull/120755


More information about the llvm-commits mailing list