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
Event Timeline
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