Added Remark messages for Loop Versioning LICM Pass to get the remark messages while using opt-viewer tool.
Thanks for working on this!
Please include diff context for the change. See https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface how to generate the diff.
It's usually useful to output the actual numbers. See how we do that in Inliner.cpp where we include the cost and the threshold.
Also please use the new closure API with emit. Again, see the inliner or https://reviews.llvm.org/D38285.
Working on necessary changes.
Out of curiosity would like to know the reason for using new Closure API with emit for some places and not for all places (as in Inliner.cpp).
I only converted a few in order to test the approach. @vivekvpandya is converting most other places.
We should convert all unless the emit call is already guarded by allowExtraAnalysis. There is also one more subtle case that cannot be converted when instead of the passname PrintAll is passed.
Number of runtime checks (<number>) exceeds threshold (<threshold>)
Can this actually return the instruction as well and then we can use that for the location rather than the entire loop.
Same here if possible.
Versioned loop for LICM. Please remove the new line everywhere.
What about to make ORE a class member?
Maybe it's better to use 'Unsafe' instead of 'Illegal'?
The message reported here is quite tricky. What I understand is: per cent of invariant memory operations in less then threshold per cent.
Do we need this remark here because remarks related to legality of instructions have already been emitted?
Maybe legalLoopMemoryAccesses should emit remarks?
That should be trivial. Take a look at how integers are emitted.
We shouldn't emit multiple remarks for a single problem, if that is what you mean. If legalLoopInstructions has already emitted something, please don't emit anything here.
If you want to mention the loop in the remark in legalLoopInstructions, you should be able to do that. We can already insert DebugLoc into the stream, there should be examples in other passes.
Alternatively, you can use the loop location for the main DebugLoc of the remark and insert the Instruction via an NV. Opt-viewer would display that as a link to the instruction in the code.
Can we mention how many checks we had to insert?
Sorry, don't follow. 'legalLoopMemoryAccesses' is a member function. It has the same access to CurLoop as isLegalForVersioning.