This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Question on GIMPLE semantics and EH (with possible easy long-term solution)


>    I don't suppose F36b has DECL_ARTIFICIAL set?  
>
>Yeah, it sure does!  Ada sets it for any variable that doesn't directly
>correspond to a user-level variable.
>
>    If it does, then that would explain the mistake -- the gimplifier
>    thinks it already *is* a temporary.
>
>    If so, we'll have to some up with some other way to identify
>    gimple temporaries.

That seems like the right thing to do, in both the short and the long run.

I believe the code is in tree-gimple.c:
bool
is_gimple_tmp_var (tree t)
{
  /* FIXME this could trigger for other local artificials, too.  */
  return (TREE_CODE (t) == VAR_DECL && DECL_ARTIFICIAL (t)
          && !TREE_STATIC (t) && !DECL_EXTERNAL (t));
}

It was fun to notice that the code already says this needs to be fixed.  :-)

One fairly clean method would be to introduce a new flag to decl.

The idea of a flag on a decl which says 
"This variable is assigned before first use, and always holds the same value"
is not bad at all and might be useful in other places as well.

So we'd
have to decide whether to have a generic flag like that (and still
check DECL_ARTIFICAL as well), or have a flag *just* for gimple temps.

The flag would be set on decls in create_tmp_var_raw () in gimplify.c and
checked in is_gimple_temp_var.  Seems simple enough.  It can go after
possibly_inlined (in tree_decl) in one of the 15 unused bits, so it can't
cost memory.

--
However, in fact, is .constant_flag/TREE_CONSTANT, or perhaps
.invariant_flag/TREE_INVARIANT appropriate enough?  Does one of these
perhaps (when used on a VAR_DECL) guarantee enough behavior that
any other temporary variable with it can just be treated as an SSA temporary?

--
An alternate (but somewhat questionable) method would be to wrap every
GIMPLE temporary in an SSA_NAME; then you could check whether it was an
SSA_NAME to see whether it was in SSA form.  But you'd have to unwrap it
to check whether it was DECL_ARTIFICAL, and other uses of SSA_NAME might
have to be changed, and so on....  It would also incur memory cost, of
course.

-- 
This space intentionally left blank.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]