Deduce "align" attribute in attributor.
Details
Diff Detail
Event Timeline
@jdoerfert
I know align attribute is integer attribute and we need somewhat different deduction with other attributes. However, I implement AAAlignImpl as a subclass of BooleanState for now. Is it better to add some base class for the integer attribute?
llvm/test/Transforms/FunctionAttrs/align.ll | ||
---|---|---|
36 | I want to test this for if (ICS && ICS.hasRetAttr(Attribute::Alignment)) return CompareOrSet(ICS.getRetAlignment()); but it does not work well now. |
Why not make it derive from IntegerState and use the integer as the alignment, zero would be the worst possible = unknown.
llvm/include/llvm/Transforms/IPO/Attributor.h | ||
---|---|---|
711 | Please add getters for the assumed and known alignment here. | |
llvm/lib/Transforms/IPO/Attributor.cpp | ||
1885 | Can you unify the two initialize methods in the base class (AAAlignImpl) with the index trick used in addIfNotExistent? | |
1909 | What you want to do use to take the minimum of all align values and the current state (IntegerState). Remember the state at the beginning of this function to determine if it changed. We also need a test for this. | |
1921 | For the return value you should do two things (for now):
Later, 1) would be replaced by a new ValueTracking.h getPointerAlignment method that does traversal, e.g., look through casts, compute new alignment based on constant geps, etc. You can work on the later points as well if you want. | |
1941 | There is (probably) no need for the ExistsAssume trick here, you can leave it but add a comment to explain that it is a shortcut to identify an optimistic fixpoint. | |
llvm/test/Transforms/FunctionAttrs/align.ll | ||
23 | We want align 4 here. |
llvm/lib/Transforms/IPO/Attributor.cpp | ||
---|---|---|
329 | I think you want to return -1 so it is clearly not a valid argument position. | |
832 | return value or argument, right? | |
836 | One could use the existing attribute as "known" and not indicate a fixpoint so that we can compute a better value. | |
846 | Why the if? Can't you take the minimum of the knownAlign and the maximum allowed? Or initialize the assumed to the maximum allowed value already in the initialization? | |
847 | style: remove braces around single statements. | |
898 |
"If no assumed state was used for reasoning, an optimistic fixpoint is reached earlier." | |
1872 | I think you want to first look at the in-flight AAAlign attribute before you look at the IR. | |
llvm/test/Transforms/FunctionAttrs/align.ll | ||
43 | Can we have SCC tests as well |
llvm/lib/Transforms/IPO/Attributor.cpp | ||
---|---|---|
1977 | Are the statistics missing? | |
1981 | Make the 1U << 29 a static const member with a proper name and description. | |
1985 | The state is not initialized here as above. Call the general constructor from the specialized one (above) to avoid such inconsistencies. | |
2023 | I think we should, for consistency, call getAssumedAlign() here. | |
2383 | remove isPointerTy, see above. | |
llvm/test/Transforms/FunctionAttrs/align.ll | ||
44 | What happened to test5 again? Why is it commented out? | |
58 | Please add a more meaningful SCC test, 3 functions, conditionals, malloc, etc. This one is a no-return recursion for which we can deduce everything. | |
76 | check the call sites. |
Please add getters for the assumed and known alignment here.