cloneLoopWithPreheader() does not update LoopInfo for sub-loop of
the original loop being cloned. Add assert to ensure no sub-loops for loop being cloned.
Details
Diff Detail
Event Timeline
Good point, thanks.
Can you please also add an assert to check that there are no subloops in OrigLoop?
We could also rename the function to cloneInnerLoopWithPreheader?
Hey sorry I'd forgotten about this patch. I'll work on it and resubmit in a day or two.
[Cloning] Add assert to ensure no sub-loops for loop being cloned. Also rename
function to reflect its inability to clone sub-loops. (It can clone sub-loops,
but does not correctly update LoopInfo).
- Updating D15922: [NOP][Cloning] Add comment to cloneLoopWithPreheader() mentioning that it does not update LoopInfo for sub-loops.
include/llvm/Transforms/Utils/Cloning.h | ||
---|---|---|
224–225 | may not => should not | |
lib/Transforms/Utils/CloneFunction.cpp | ||
705–707 | may not => should not | |
706 | cloneInnerLoopWithPreheader looks little confusing, consider L1 { L2{ L3{} } }, L2 is also a inner loop, But here we clone innermost loop only. How about cloneInnermostLoopWithPreheader ? | |
712 | Please assert with some message, i.e. Loop is not innermost |
Thanks Vaivaswatha, looks OK to me except the name of function.
As I mentioned earlier ‘cloneInnermostLoopWithPreheader’ looks more intuitive
vs ‘cloneInnerLoopWithPreheader’ because we clone the innermost loop only.
Adam, Hal:
What’s your opinion on this name change ?
I see lot of indentation problems here, please correct them.
Try using clang-format its useful.
lib/Transforms/Scalar/LoopDistribute.cpp | ||
---|---|---|
125–126 | Correct indentation | |
129–130 | Correct indentation | |
lib/Transforms/Utils/CloneFunction.cpp | ||
706 | Correct indentation. | |
712 | Correct indentation. | |
lib/Transforms/Utils/LoopVersioning.cpp | ||
106 | Correct indentation. |
Indentation is still not as per llvm coding standard, please run clang-format.
You can specifically run it on the code added by you using below command:
$ clang-format -i -lines=start:end <file>
Refer below page for more details:
http://clang.llvm.org/docs/ClangFormat.html
Upon reflection, cloning an outer loop is something we'll want to be able to do at some point. Why don't we just add the assertion for now, and then fix the function once we have a concrete use case?
(TODO comments in header files are discouraged)