On Wed, May 18, 2011 at 6:55 PM, Feng LI <nemoking...@gmail.com> wrote: > Hi Richard, > > a_2 is used in g1 already, I don't know how this data structure is > managed and afraid that it'll be freed twice if you also use it in the > newly inserted stmt. Do you think it'll be safe here?
Of course it is. SSA names can be used multiple times just fine. Richard. > Feng > On Wed, May 18, 2011 at 6:10 PM, Richard Guenther > <richard.guent...@gmail.com> wrote: >> On Wed, May 18, 2011 at 5:01 PM, Feng LI <nemoking...@gmail.com> wrote: >>> Hi, >>> >>> I have the code like: >>> a_2 = 5; g1 >>> b_3 = 6; g2 >>> d_4 = a_2 + b_3; g3 >>> >>> And I'd like to insert "tmp.globe = a_2" just after the definition of >>> a_2 (after g1), so that the code will be: >>> >>> a_2 = 5; g1 >>> tmp.globe = a_2; inserted code >>> b_3 = 6; g2 >>> d_4 = a_2 + b_3; g3 >>> >>> This pass is with SSA form, and I write code like: >>> >>> tree use = make_ssa_name (var, NULL); //create a_11 >>> /* Set the DEF_P (referred to a_2) to be the DEF of the newly created USE. >>> */ >>> SET_DEF (def_p, use); >>> >>> But this will invalidate the original USE-DEF chain, where the a_11 defined >>> in g1 will never match the use in g3 of a_2, and the code will look like: >>> >>> a_11 = 5; g1 >>> tmp.globe = a_11; inserted code >>> b_3 = 6; g2 >>> d_4 = a_2 + b_3; g3 >>> >>> It seems that I have to update all the use of the original a_2 again and set >>> the use to a_11. Is there some solutions that I don't have to update the >>> def-use chains manually? >> >> Why do you allocate a new a_11 instead of using a_2? >> >> Richard. >> >>> Thanks, >>> Feng >>> >> >