[llvm-dev] Particular type of loop optimization

Gleison Souza via llvm-dev llvm-dev at lists.llvm.org
Sun Feb 7 16:12:50 PST 2016


Dear all,

I'm trying to determine the boundaries speculatively.

> Some more robust alternative scheme would be to use pragmas instead of
comment
and have the front-end parse These pragma and lower the information you
want in
something like llvm.assume.

> I'm a bit confused too. I have no idea how to "know" that `V` is an array
with stable limits in your example. That would highly depend on the call to
`foo`, Which you have not given in your example - and from a C or C ++
perspective, Could be just about any pointer to` int`, from a single int
variable having its address taken , to a dynamically allocated result of
`std :: vector <int> :: data () '- or` malloc`, `new`, the local variable -
including variable length arrays with runtime determined bounds.

I'm trying to determine the boundaries just analyzing the IR, the tool
inserts the
comment of automatic form.

> This example, of the one you sent just before (without global variable),
does not have a load for the base address in the IR optimized.

Yes, I sent as an example of what I'm doing. Apparently, no optimization is
so powerful,
because in some situations, alias occurrence prevents me to estimate the
limits, as it can
prevent other tools to estimate the boundaries similarly.

Thanks for help.

    Gleison

2016-02-03 21:34 GMT-02:00 mats petersson <mats at planetcatfish.com>:

> I'm a bit confused too. I have no idea how to "know" that `v` is an array
> with stable limits in your example. That would highly depend on the call to
> `foo`, which you haven't given in your example - and from a C or C++
> perspective, could be just about any pointer to `int`, from a single int
> variable having its address taken, to a dynamically allocated result of
> `std::vector<int>::data()` - or `malloc`, `new`, local variable - including
> variable length arrays with runtime determined bounds.
>
> Also, I don't see why the variable being accessed inside or outside the
> loop will matter? Surely it's just a matter of determining that it's a GEP
> instruction, and understanding what its `base` is, regardless of where that
> source is?
>
> My Pascal compiler has (partial) support for range-checking, but I guess
> this works better in Pascal where arrays always have a fixed size [well, at
> least in my implementation, which doesn't have Borland/Turbo Pascal
> extensions passing the array bounds to the function], and can't by, for
> example, dynamically sized.
>
> However, debug symbols should be maintained by LLVM, as long as you use
> `-g`, even if some code gets moved around, the original location of that is
> maintained (in my experience at least, both with debugging clang-generated
> code and adding debug info to my own compiler).
>
> --
> Mats
>
>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160207/25706a49/attachment.html>


More information about the llvm-dev mailing list