Hi,<br><br>The attached patch is to improve the memory footprint of pass GlobalOpt. <span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);display:inline!important;float:none">Please kindly let me know if the patch is good to commit.<br>

I also attached a case to repeat the issue, on which 'opt -globalopt' consumes 3.2GB memory and is stuck for long time. <br>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@2.40GHz, 16GB)<br>

<br>The big memory footprint cause is that current GlobalOpt one by one hoists and stores the leaf element constant into the global array, <br>in each iteration, it recreates the global array initializer constant and leave the old initializer alone. This may result in many obsolete constants left.<br>

For example:  we have global array @rom = global [16 x i32] zeroinitializer<br>After the first element value is hoisted and installed:   @rom = global [16 x i32] [ 1, 0, 0, ... ]<br>After the second element value is installed:  @rom = global [16 x 32] [ 1, 2, 0, 0, ... ]        // here the previous initializer is obsolete<br>

...<br>When the transform is done, we have 15 obsolete initializers left useless.<br><br><br><br>-Sheng<br></span>