Add an ability to provide an output argument to store loop exit edges
with pair of const and non-const BasicBlocks.
Details
Diff Detail
Event Timeline
include/llvm/Analysis/LoopInfo.h | ||
---|---|---|
282 | Is there a reason why the implementation was moved to here? Could it stay in LoopInfoImpl.h? |
include/llvm/Analysis/LoopInfo.h | ||
---|---|---|
282 | Yes, there is a reason. To support both const and non-const ParamBlockT in SmallVector argument I introduced the new template parameter ParamBockT. As a result if I keep the implementation in LoopInfoImpl.h I have a compilation error due to users includes this header. So the movement to this header is required. |
include/llvm/Analysis/LoopInfo.h | ||
---|---|---|
282 | On second thought, it looks like getExitEdges has only a single user, so maybe it would be better to just change the original API from const to non-const and update LoopPredication? This would be in line with most of the other APIs, that already return non-const BlockT*, exactly for the reason that most APIs expect non-const blocks. |
include/llvm/Analysis/LoopInfo.h | ||
---|---|---|
282 | I can do this. |
include/llvm/Analysis/LoopInfo.h | ||
---|---|---|
282 | Nothing per-se, IMO it is just slightly preferable to keep the changes as simple as possible/required; and given most other functions in LoopBase already return non-const, it seems reasonable to bring getExitEdges in line. (Potential drawbacks are increased compile-time/size, as LoopInfo.h is widely used and it adds an additional step to git-blame) |
Given all the other APIs on this class work in terms of BlockT*, not const BlockT*, I think it would be more consistent to just change the definition of Edge in this case. The one caller should be trivial to update.
In theory, being const correct is better, but consistency in the code overrides to me.
If you want to make the suggested change to Edge, feel free to submit without further review.
Is there a reason why the implementation was moved to here? Could it stay in LoopInfoImpl.h?