This patch adds deduction for the MaxObjSize attribute in the
Attributor. If an object is globally defined or has been defined with an
alloca instruction, it's not resizable and we immediately converge to
the size. For objects that are captured, we assume the pessimistic
fixpoint because the objects may be resized, and we iterate for the
rest.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/test/Transforms/Attributor/maxobjsize.ll | ||
---|---|---|
174 | add another use of %0 and @G here before the capture calls | |
174 | This is not necessary, forgot to delete it. | |
190 | duplicate the test so it exists 3 times. In this version we can actually add maxobjsize to the call site argument, we can do so as well if the use is not reachable from a capturing use. We don't need to add the logic but the test might be worth adding with a fixme. |
llvm/lib/Transforms/IPO/AttributorAttributes.cpp | ||
---|---|---|
3843 | This can be null. We need to check it and abort. |
llvm/lib/Transforms/IPO/AttributorAttributes.cpp | ||
---|---|---|
3797 | you need a new statistics tracker here and elsewhere |
CTMark, O3 with attributor before and after these patches
0) before_attr.json.stats vs after_attr.json.stats CHANGED: codegenprepare NumExtsMoved 3631 -> 3699 ( +1.873%) CHANGED: dse NumFastOther 192 -> 194 ( +1.042%) CHANGED: gvn IsValueFullyAvailableInBlockNumSpeculationsMax 4958 -> 5060 ( +2.057%) CHANGED: gvn NumGVNInstr 46657 -> 47534 ( +1.880%) CHANGED: jump-threading NumDupes 91 -> 92 ( +1.099%) CHANGED: licm NumMovedLoads 6272 -> 6344 ( +1.148%) CHANGED: licm NumPromoted 381 -> 438 ( +14.961%) CHANGED: loop-rotate NumNotRotatedDueToHeaderSize 31 -> 29 ( -6.452%) CHANGED: machinelicm NumPostRAHoisted 88 -> 89 ( +1.136%) CHANGED: memdep NumCacheNonLocalPtr 1005887 -> 1016671 ( +1.072%) CHANGED: memory-builtins ObjectVisitorLoad 62048 -> 63473 ( +2.297%) CHANGED: peephole-opt NumCmps 532 -> 526 ( -1.128%) CHANGED: regalloc NumDCEFoldedLoads 27 -> 26 ( -3.704%) CHANGED: regalloc NumLocalSplits 1891 -> 1870 ( -1.111%)
Can you add these examples too please:
void use(int *a) { *a += 1; } static void non_resizable(int *p) { use(p); use(p); } static void resizable(int *p) { use(p); use(p); } void non_resizable_caller1() { int a; non_resizable(&a); } int G; void non_resizable_caller2() { non_resizable(&G); } void resizable_caller1() { int a; resizable(&a); } void resizable_caller2(int *a) { resizable(a); }
llvm/lib/Transforms/IPO/AttributorAttributes.cpp | ||
---|---|---|
3746 | Why not the assumed state? |
llvm/test/Transforms/Attributor/maxobjsize.ll | ||
---|---|---|
493 | Can you run mem2reg on the new test code. Also add maxobjsize to the argument %0 in this caller, I forgot to mention that. The test should show that we propagate maxobjsize to the second use *only* if it is not resizable. |
Make it StateType