The patch is to improve the memory footprint of pass GlobalOpt.
authorZhou Sheng <zhousheng00@gmail.com>
Sat, 1 Dec 2012 04:38:53 +0000 (04:38 +0000)
committerZhou Sheng <zhousheng00@gmail.com>
Sat, 1 Dec 2012 04:38:53 +0000 (04:38 +0000)
commit702aa2ee19132593b552d211c985aa540787c197
treed2b4219bc2bca91ac6c71882afdef9419f506f33
parent2587a8a18c55116b339d4b47d441512067e9c96b
The patch is to improve the memory footprint of pass GlobalOpt.
Also check in a case to repeat the issue, on which 'opt -globalopt' consumes 1.6GB memory.
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169079 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/IPO/GlobalOpt.cpp
test/Transforms/GlobalOpt/big-memory-footprint.ll [new file with mode: 0644]