[cfe-dev] How can I attach range metadata from clang?

Jon Chesterfield via cfe-dev cfe-dev at lists.llvm.org
Wed Nov 7 08:55:24 PST 2018


Range metadata can be set on load and call of integer types in IR. I can
hit significantly better codegen if the IR has range annotations on
variables.

My first attempt used llvm.assume, but this doesn't appear to influence
range metatdata or scalar evolution.

The code I'm working with is written in C++, compiled via clang. I'd like
the authors to annotate the range on variables. Intrinsics, existing or
bespoke, would be fine. Ideally the method would work on variables, but
failing that annotating loads would still help.

I tried routing the count via alloca/store/load, with metadata on the load,
but this is eliminated before reaching my pass. If I force matters, the
trip via the stack thwarts scalar evolution anyway. Similarly a call that
is eliminated later blocks scalar evolution.

I'm reasonably confident that an intrinsic that lowers to a load
instruction will work but haven't cut the code yet. It wouldn't be as
general as an int (*)(int) intrinsic either.

How should I approach this?

Thanks!

Jon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20181107/93caa2fc/attachment.html>


More information about the cfe-dev mailing list