On Thu, Jan 24, 2013 at 5:15 PM, Richard Biener <richard.guent...@gmail.com> wrote: > > On Thu, Jan 24, 2013 at 7:06 AM, Sudakshina Das > <sudakshina1...@gmail.com> wrote: > > Dear all, > > > > I am currently updating a pass that was made for gcc-4.6.*, so that it > > works for gcc.4.7.2. > > > > In the pass for gcc-4.6.*, a code fragment from tree-ssa-structalias.c > > was picked up and used. > > Given below is the fragment taken form create_function_info_for () . > > This fragment was used to create variable information for the function > > and it was picked up to perform a similar operation in the added pass > > as well. > > > > But in gcc-4.7.2 some changes are introduced in the fragment. The code > > given below shows the changes that have been introduced in > > create_function_info_for () of tree-ssa-structalias.c in gcc-4.7.2 > > along with the original code in the comments. > > > > /* Add one representative for all further args. */ > > if (is_varargs) > > { > > varinfo_t argvi; > > const char *newname; > > char *tempname; > > tree decl; > > > > asprintf (&tempname, "%s.varargs", name); > > newname = ggc_strdup (tempname); > > free (tempname); > > > > /* We need sth that can be pointed to for va_start. */ > > > > /**************** CHANGED CODE in GCC-4.7.2 ***************/ > > decl = build_fake_var_decl (ptr_type_node); > > > > /************ ORIGINAL CODE in GCC-4.6.2 ******************* > > /* decl = create_tmp_var_raw (ptr_type_node, name); > > get_var_ann (decl); > > */ > > > > argvi = new_var_info (decl, newname); > > argvi->offset = fi_parm_base + num_args; > > argvi->size = ~0; > > argvi->is_full_var = true; > > argvi->is_heap_var = true; > > argvi->fullsize = vi->fullsize; > > gcc_assert (prev_vi->offset < argvi->offset); > > prev_vi->next = argvi; > > prev_vi = argvi; > > } > > > > return vi; > > > > > > So I made the same changes in the pass where this fragment was used. > > But after making the changes the pass is now giving an "internal > > compiler error" and a "segmentation fault" at runtime. > > > > After debugging I could narrow it down to the function > > build_fake_var_decl() and to be specific at the memory allocation > > statement highlighted below. > > > > > > tree > > build_fake_var_decl (tree type) > > { > > /************************ My debugging showed that the control came > > here *********************/ > > tree decl = (tree) XOBNEW (&fake_var_decl_obstack, struct tree_var_decl); > > /************************ But did not come here > > **********************************************************/ > > memset (decl, 0, sizeof (struct tree_var_decl)); > > TREE_SET_CODE (decl, VAR_DECL); > > TREE_TYPE (decl) = type; > > DECL_UID (decl) = allocate_decl_uid (); > > SET_DECL_PT_UID (decl, -1); > > layout_decl (decl, 0); > > return decl; > > } > > > > The builf_fake_var_decl() function is a gcc function defined in > > tree-ssa-structalias.c. To be able to use it in my pass, I removed the > > keyword static in its definition. > > > > I cannot figure out what can possibly cause this error in the XOBNEW > > function. > > > > Please help!!! > > Don't use build_fake_var_decl, use what 4.6 did, create_tmp_var_raw. > > Richard. > >
But 4.6 used get_var_ann() also along with create_tmp_var_raw() which has been removed from 4.7. > > Sudakshina Das