Changes the size of allocations automatically.
Only implements the case when a single range from start of the allocation is alive.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Event Timeline
High level: Merge the test in one file. Use descriptive names for functions. remove the printf and other stuff that is not useful.
llvm/lib/Transforms/IPO/AttributorAttributes.cpp | ||
---|---|---|
12310 | Manifest is only called if the state is valid at the end. It looks like you duplicate lots of checks here that should not be necessary. | |
12412–12417 | Assertion, this should never be the case, right? | |
12419–12421 | The lambda is called only once, right? Why use a lambda at all? |
llvm/lib/Transforms/IPO/Attributor.cpp | ||
---|---|---|
3551–3553 | ||
llvm/lib/Transforms/IPO/AttributorAttributes.cpp | ||
874 | Call it numBins or sth, to make it clear. Size could be a lot of things in this context. | |
12208 | no this-> | |
12210 | This is just getIRPosition(). | |
12218 | Why would we want to have the same value twice, use the pointer. | |
12220–12222 | Style, also elsewhere. | |
12224 | We should not cast things to the Impl. Expose the functions you need in the AAPointerInfo interface instead. | |
12240 | I think A.getDataLayout() is a thing too. | |
12265–12267 | Make this an assertion, manifest will not be called on invalid states. |
llvm/lib/Transforms/IPO/AttributorAttributes.cpp | ||
---|---|---|
12224 | I think it might make sense to expose the state in the AAPointerInfo struct. |
llvm/lib/Transforms/IPO/AttributorAttributes.cpp | ||
---|---|---|
12220 | ||
12228 | Don't cast it to an "Impl". There is no need anymore anyway. | |
12229 | State could be anything. At least call it PIState. | |
12233–12239 | This is basically BinSize != 1, return, no? | |
12252 | Why does this not trigger for the ptr/i64 case? Is one of them in bytes the other in bits? | |
12255 | This is fine for OffsetEnd = 2,4,8, but then it becomes a little iffy. Check for non default sizes and go with a char array instead. | |
12273 | Same as above. | |
llvm/test/Transforms/Attributor/value-simplify-local-remote.ll | ||
82 ↗ | (On Diff #551856) | This doesn't actually make it smaller, we should avoid such changes. |
135 ↗ | (On Diff #551856) | Same here. |
Revision based on comments
llvm/lib/Transforms/IPO/AttributorAttributes.cpp | ||
---|---|---|
12233–12239 | umm, I think BinSize == 0 | |
12252 | if its a ptr public: std::optional<TypeSize> getAllocationSize(const DataLayout &DL) returns a size of 0 which is why that if condition is not triggered. |
llvm/lib/Transforms/IPO/AttributorAttributes.cpp | ||
---|---|---|
12261 | Why do you give up on struct type like {i32, i32}? |
llvm/lib/Transforms/IPO/AttributorAttributes.cpp | ||
---|---|---|
12261 | I was trying to indicate a fix point for structs like |
llvm/lib/Transforms/IPO/Attributor.cpp | ||
---|---|---|
3558 | Better to use [[maybe_unused]] now. |
llvm/lib/Transforms/IPO/AttributorAttributes.cpp | ||
---|---|---|
12223–12224 | As I said before, no casting to implementations of the interface. put the method you need into AAPointerInfo. | |
12272–12274 | ||
llvm/test/Transforms/Attributor/value-simplify-local-remote.ll | ||
384 ↗ | (On Diff #552461) | unrelated, just keep the old version of this file. |
1.) Insert a new instruction instead of modiying the old one (Char array)
2.) Restore value-simplify-local-remote.ll
3.) Add a new positive test to reduce size of array alloca
llvm/include/llvm/Transforms/IPO/Attributor.h | ||
---|---|---|
5953 | This is not a good idea. What happend to the old API you had? |
llvm/include/llvm/Transforms/IPO/Attributor.h | ||
---|---|---|
5953 | Yeah I see. |
llvm/lib/Transforms/IPO/Attributor.cpp | ||
---|---|---|
3558 | Then there is no need (void)Success;. |
Support for modifying malloc instructions
TODO: The original malloc call is not being removed by changeAfterManifest even though it is dead.
Don't call AAPointerInfoGetOrCreate other than Alloca and Malloc Instruction. Results in infinite loop for instance when calling a ptr
Add new test where argument to malloc isn't a constant.
Use AAPotentialConstantValues to get the constant value.
New example and question about what the optimization should do for an example like @baz in allocator.ll
This is not a good idea. What happend to the old API you had?
We do not want to leak out the underlying map if we don't have to.
All you want is a size and begin/end, no?