Repository navigation
C++: Change range-analysis test to not use getAst - #13294
Conversation
…g confusing test expectation annotations.
|
I'm getting very confused by all the |
Good point. I'll play around with some different separators and see what I like best. |
|
@jketema I've changed the separator from I also have a branch locally that adds immediate strings to |
Thanks! |
For a while we were confused about this range-analysis test:
because the inline-expectations test annotation seemed to suggest that range-analysis was claiming that
iwas bounded upper bounded by the return value of the call tof3_get(which totally didn't make any sense). However, as @jketema correctly hypothesized, this was actually caused by the fact that we were usingInstruction.getAstto obtain a string-representation of the bound. Dropping the use ofgetAst(as I've done in PR) reveals what's really going on:which shows that
iis upper bounded by a phi instruction generated on the linewhile (f3_get(n)) n+=2;(which makes a lot more sense 🎉).Motivated by the above, this PR rewrites our range-analysis tests to not use
getAst. This rewrite reveals that a lot of our bounds are phi instructions, and it would probably make sense to improve the string-representation of these bounds somehow. Currently, thetoStringon the bounds just output whatevertoStringdoes on instructions, and onPhiInstruction's that's the wordPhi:followed by the first thing in the basic block in which the phi instruction occur (which is why we see=Phi: call to f3_getabove). A reasonable follow-up to this PR would be to enrich the output ofPhiInstruction'stoStringto print the name of the variable tracked by thePhiInstruction(if any) so that the test would become:I'll leave that to a follow-up PR, though.