<div dir="ltr"><div>Dear all,</div><div><br></div><div>I'm trying to determine the boundaries speculatively.</div><div><br></div><div>> Some more robust alternative scheme would be to use pragmas instead of comment</div><div>and have the front-end parse These pragma and lower the information you want in</div><div>something like llvm.assume.</div><div><br></div><div>> 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.</div><div><br></div><div>I'm trying to determine the boundaries just analyzing the IR, the tool inserts the</div><div>comment of automatic form.</div><div><br></div><div>> 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.</div><div><br></div><div>Yes, I sent as an example of what I'm doing. Apparently, no optimization is so powerful,</div><div>because in some situations, alias occurrence prevents me to estimate the limits, as it can</div><div>prevent other tools to estimate the boundaries similarly.</div><div><br></div><div>Thanks for help.</div><div><br></div><div>    Gleison</div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-02-03 21:34 GMT-02:00 mats petersson <span dir="ltr"><<a href="mailto:mats@planetcatfish.com" target="_blank">mats@planetcatfish.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>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.<br><br></div><div>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?<br></div><div><br></div>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.<br><br></div>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).<br><br>--<br></div>Mats<br><div><br><br>​</div></div>
</blockquote></div><br></div>