[llvm-dev] Particular type of loop optimization
mats petersson via llvm-dev
llvm-dev at lists.llvm.org
Wed Feb 3 15:34:08 PST 2016
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/20160203/e479c6bf/attachment.html>
More information about the llvm-dev
mailing list