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 | ||
---|---|---|
12776 | 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. | |
12878–12883 | Assertion, this should never be the case, right? | |
12885–12887 | The lambda is called only once, right? Why use a lambda at all? |
llvm/lib/Transforms/IPO/Attributor.cpp | ||
---|---|---|
3646–3648 | ||
llvm/lib/Transforms/IPO/AttributorAttributes.cpp | ||
885 | Call it numBins or sth, to make it clear. Size could be a lot of things in this context. | |
12674 | no this-> | |
12676 | This is just getIRPosition(). | |
12684 | Why would we want to have the same value twice, use the pointer. | |
12686–12688 | Style, also elsewhere. | |
12690 | We should not cast things to the Impl. Expose the functions you need in the AAPointerInfo interface instead. | |
12706 | I think A.getDataLayout() is a thing too. | |
12731–12733 | Make this an assertion, manifest will not be called on invalid states. |
llvm/lib/Transforms/IPO/AttributorAttributes.cpp | ||
---|---|---|
12690 | I think it might make sense to expose the state in the AAPointerInfo struct. |
llvm/lib/Transforms/IPO/AttributorAttributes.cpp | ||
---|---|---|
12686 | ||
12694 | Don't cast it to an "Impl". There is no need anymore anyway. | |
12695 | State could be anything. At least call it PIState. | |
12699–12705 | This is basically BinSize != 1, return, no? | |
12718 | Why does this not trigger for the ptr/i64 case? Is one of them in bytes the other in bits? | |
12721 | 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. | |
12739 | 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 | ||
---|---|---|
12699–12705 | umm, I think BinSize == 0 | |
12718 | 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 | ||
---|---|---|
12727 | Why do you give up on struct type like {i32, i32}? |
llvm/lib/Transforms/IPO/AttributorAttributes.cpp | ||
---|---|---|
12727 | I was trying to indicate a fix point for structs like |
llvm/lib/Transforms/IPO/Attributor.cpp | ||
---|---|---|
3653 | Better to use [[maybe_unused]] now. |
llvm/lib/Transforms/IPO/AttributorAttributes.cpp | ||
---|---|---|
12689–12690 | As I said before, no casting to implementations of the interface. put the method you need into AAPointerInfo. | |
12738–12740 | ||
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 | ||
---|---|---|
6127 | This is not a good idea. What happend to the old API you had? |
llvm/include/llvm/Transforms/IPO/Attributor.h | ||
---|---|---|
6127 | Yeah I see. |
llvm/lib/Transforms/IPO/Attributor.cpp | ||
---|---|---|
3653 | 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?