This function abstract attribute identifies whether the loops in a function are
"always-endless" or "never-endless". We can use such information to improve
the deduction of "willreturn" and undefined behavior.
Details
Diff Detail
Unit Tests
Event Timeline
llvm/lib/Transforms/IPO/AttributorAttributes.cpp | ||
---|---|---|
7948–7952 | I don't think this is correct. |
llvm/lib/Transforms/IPO/AttributorAttributes.cpp | ||
---|---|---|
7948–7952 | I am sorry I ment never endless. in the 3th line phab won't let me change the inline comment. |
llvm/lib/Transforms/IPO/AttributorAttributes.cpp | ||
---|---|---|
7942 | Instead of looping every instruction, you can use getTerminator() and check if it's a branch. | |
7943 | For that to make sense, you have to verify that the branch isConditional(). Also, note that loops Generally, loops can get quite complicated and so, as Kuter said, you probably want to use |
llvm/lib/Transforms/IPO/AttributorAttributes.cpp | ||
---|---|---|
7943 | FWIW, AAConstantRange actually uses SCEV internally but I agree that using AAConstantRange might make things complicated as a starting point. So you can use SCEV first. |
llvm/lib/Transforms/IPO/AttributorAttributes.cpp | ||
---|---|---|
7943 | Yes, but the point is that using constant range directly makes things difficult because we have to re-deduce information and loop structure that SCEV is supposed to handle (e.g. the code above is doing something similar to backedge taken count). |
llvm/lib/Transforms/IPO/AttributorAttributes.cpp | ||
---|---|---|
7943 | Thanks for the idea.
|
llvm/lib/Transforms/IPO/AttributorAttributes.cpp | ||
---|---|---|
7943 |
We have tests for loop terminations in a test for willreturn (I guess) |
llvm/lib/Transforms/IPO/AttributorAttributes.cpp | ||
---|---|---|
7943 |
But even with an always true condition, you're not sure the loop is endless. while (some condition that is always true) { if (some condition that makes the loop stop at some point) break; } Which brings us again to the initial point: It seems using SCEV is the only sane way. SCEV is
For what ?
@uenoku should be able to help you here. |
llvm/lib/Transforms/IPO/AttributorAttributes.cpp | ||
---|---|---|
7943 |
Maybe we can first check the loop is canonicalized or not. If the loop is LCSSA, things get easier. |
llvm/lib/Transforms/IPO/AttributorAttributes.cpp | ||
---|---|---|
7943 | Thanks for the idea here. I will take a look at it. |
llvm/lib/Transforms/IPO/AttributorAttributes.cpp | ||
---|---|---|
7943 |
How would LCSSA help ? Btw, @bbn if you want to read about LCSSA or other canonical forms, you can check this: https://llvm.org/docs/LoopTerminology.html
I mean yes, ideally SCEV would do its thing by taking advantage of the Attributor. But right now, it's certainly a bad idea unless we have a good plan for it. |
llvm/lib/Transforms/IPO/AttributorAttributes.cpp | ||
---|---|---|
7943 | I thought we can use SCEV more easily and discuss the exit conditions more simply by restricting the loop form. However, Come to think of it, LCSSA itself doesn't help the dedication. Sorry for confusion;)
Yes, I agree |
clang-tidy: warning: non-void function does not return a value [clang-diagnostic-return-type]
not useful