[llvm-commits] [PATCH] Memory footprint improvement of pass GlobalOpt

Sheng Zhou zhousheng00 at gmail.com
Thu Nov 29 17:57:27 PST 2012


I think we need to keep the insertion order of the obsolete constants,
because the global variable initializer is created in hierachical way which
is bottom up. Therefore, we need to delete the obsolete ones in topdown
way. For example:

@rom = global [16 x [1024 x i32]] [[1, 2, 3, ...,1024 ] [2, 4, ...2048] ...
]

For the above global variable, we also generate 16 constants [1024 x i32]
before we generate the initializer every time, so when we delete the
obsolete initializer, we need to  make sure we delete the 16 [1024xi32]
after [16 x [1024 x i32]] is deleted, otherwise there will be non-use-empty
issue.


-Sheng

On Thu, Nov 29, 2012 at 11:14 PM, Jakub Staszak <kubastaszak at gmail.com>wrote:

> Any particular  reason you use SetVector? It looks like insertion order
> doesn't make any difference, so SmallPtrSet should be cheaper.
>
> - Kuba
>
>
>  On Thu, Nov 29, 2012 at 7:45 AM, Sheng Zhou <zhousheng00 at gmail.com>wrote:
>
>>  Hi,
>>
>> The attached patch is to improve the memory footprint of pass GlobalOpt. Please
>> kindly let me know if the patch is good to commit.
>> I also attached a case to repeat the issue, on which 'opt -globalopt'
>> consumes 3.2GB memory and is stuck for long time.
>> With my patch the memory footprint is reduced to 300MB and GlobalOpt
>> transform finishes in 3mins. (My machine info: 16 Intel(R) Xeon(R) CPU
>> E5620 at 2.40GHz, 16GB)
>>
>> The big memory footprint cause is that current GlobalOpt one by one
>> hoists and stores the leaf element constant into the global array,
>> in each iteration, it recreates the global array initializer constant and
>> leave the old initializer alone. This may result in many obsolete constants
>> left.
>> For example:  we have global array @rom = global [16 x i32]
>> zeroinitializer
>> After the first element value is hoisted and installed:   @rom = global
>> [16 x i32] [ 1, 0, 0, ... ]
>> After the second element value is installed:  @rom = global [16 x 32] [
>> 1, 2, 0, 0, ... ]        // here the previous initializer is obsolete
>> ...
>> When the transform is done, we have 15 obsolete initializers left useless.
>>
>>
>>
>> -Sheng
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121130/e20761ca/attachment.html>


More information about the llvm-commits mailing list