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)
commit13fb1ca44a9751124b07c3646e50d723514c6e36
tree6034e47c5a99ad3674abe0d5a7107c9235a4447e
parentcadf0b682d050670df4568f798bfe65dd7199003
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.

llvm-svn: 169079
llvm/lib/Transforms/IPO/GlobalOpt.cpp
llvm/test/Transforms/GlobalOpt/big-memory-footprint.ll [new file with mode: 0644]