public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* code instrumentation in the tree structure
@ 2006-09-05 10:30 Björn Skoglund
  2006-09-05 15:32 ` Ian Lance Taylor
  0 siblings, 1 reply; 3+ messages in thread
From: Björn Skoglund @ 2006-09-05 10:30 UTC (permalink / raw)
  To: gcc-help

Hi everyone

I don't know if this is a development-list issue but I thought I'd start 
here. I'm writing a code instrumentation tool using the GEM 
plugin-system (http://www.ecsl.cs.sunysb.edu/gem/) as a part of my 
thesis project. I got it working in gcc-3.4 with a little help from the 
GEM maintainer but I have realized I need to move to gcc-4 to get access 
to the control-flow manipulation tools. Now my problem is that my code 
which inserted function call statements does not work under the gcc-4 
environment. the EXPR_STMT-symbol is gone for example. which makes the line

 >t_new_stmt = build_nt(EXPR_STMT, t_call);

cause compilation errors. Now, has the notion of statements been removed 
in gcc-4, and in that case what has replaced it? I am quite confused at 
the moment so if something doesn't make sense I'd be very happy with any 
kind of explanation that makes me understand again. The following piece 
of code is what I'm working with at the moment. It compiles but doesn't 
really cause anything to happen when run.

 >void ci_insert_call(tree t_func, const char* func_name, tree args) {
 >  tree t_func_decl;
 >  tree t_body;
 >  tree t_first_stmt;
 >
 >  tree t_call;
 >  tree t_new_stmt;
 >
 >
 >  t_body=DECL_SAVED_TREE(t_func); // COMPOUND_STMT
 >/*   t_first_stmt = COMPOUND_BODY(t_body);  */
 >
 >  gem_find_symtab(&t_func_decl, func_name);
 >  t_call=build_function_call(t_func_decl, args);
 >  t_new_stmt = build_nt(CALL_EXPR, t_call);
 >/*   TREE_CHAIN(t_new_stmt)=TREE_CHAIN(t_first_stmt); */
 >/*   TREE_CHAIN(t_first_stmt)=t_new_stmt; */
 >  tree_stmt_iterator itor;
 >  itor = tsi_start(t_body);
 >  tsi_link_before(&itor, t_new_stmt, TSI_SAME_STMT);
 >}


Cheers!
/Björn Skoglund

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: code instrumentation in the tree structure
  2006-09-05 10:30 code instrumentation in the tree structure Björn Skoglund
@ 2006-09-05 15:32 ` Ian Lance Taylor
  2006-09-07 11:19   ` Björn Skoglund
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Lance Taylor @ 2006-09-05 15:32 UTC (permalink / raw)
  To: Björn Skoglund; +Cc: gcc-help

Björn Skoglund <skoglund@lysator.liu.se> writes:

> I don't know if this is a development-list issue but I thought I'd
> start here. I'm writing a code instrumentation tool using the GEM
> plugin-system (http://www.ecsl.cs.sunysb.edu/gem/) as a part of my
> thesis project. I got it working in gcc-3.4 with a little help from
> the GEM maintainer but I have realized I need to move to gcc-4 to get
> access to the control-flow manipulation tools. Now my problem is that
> my code which inserted function call statements does not work under
> the gcc-4
> environment. the EXPR_STMT-symbol is gone for example. which makes the line
> 
>  >t_new_stmt = build_nt(EXPR_STMT, t_call);
> 
> cause compilation errors. Now, has the notion of statements been
> removed in gcc-4, and in that case what has replaced it? I am quite
> confused at the moment so if something doesn't make sense I'd be very
> happy with any kind of explanation that makes me understand again. The
> following piece of code is what I'm working with at the moment. It
> compiles but doesn't really cause anything to happen when run.

gcc4 internals are very different from gcc3 internals.  That's why we
bumped the version number.  In gcc4, everything is translated into
GIMPLE, a tree based language, and works from there.

There is no need for EXPR_STMT in GIMPLE, so it was moved to the C++
frontend which continues to use it when handling templates.

Ian

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: code instrumentation in the tree structure
  2006-09-05 15:32 ` Ian Lance Taylor
@ 2006-09-07 11:19   ` Björn Skoglund
  0 siblings, 0 replies; 3+ messages in thread
From: Björn Skoglund @ 2006-09-07 11:19 UTC (permalink / raw)
  To: gcc-help

I see. I'm not sure but get the feeling i'm working in GENERIC-form. I
also found this in the internals documentation:

>Early on, there was a great deal of debate about how to think 
>about statements in a tree IL. In GENERIC, a statement is
>defined as any expression whose value, if any, is ignored. 
>A statement will always have |TREE_SIDE_EFFECTS| set (or it
>will be discarded), but a non-statement expression may also 
>have side effects. A |CALL_EXPR|, for instance.

I suppose this is what I am interested in, does anyone know when this
discussion occurred and if I can read it?

/Björn

p.s. I tried setting TREE_SIDE_EFFECTS(t_new_stmt) = 1; and
TREE_TYPE(t_new_stmt) = void_type_node; but it didn't really get me much
further.

Ian Lance Taylor wrote:
> Björn Skoglund <skoglund@lysator.liu.se> writes:
>
>   
>> I don't know if this is a development-list issue but I thought I'd
>> start here. I'm writing a code instrumentation tool using the GEM
>> plugin-system (http://www.ecsl.cs.sunysb.edu/gem/) as a part of my
>> thesis project. I got it working in gcc-3.4 with a little help from
>> the GEM maintainer but I have realized I need to move to gcc-4 to get
>> access to the control-flow manipulation tools. Now my problem is that
>> my code which inserted function call statements does not work under
>> the gcc-4
>> environment. the EXPR_STMT-symbol is gone for example. which makes the line
>>
>>  >t_new_stmt = build_nt(EXPR_STMT, t_call);
>>
>> cause compilation errors. Now, has the notion of statements been
>> removed in gcc-4, and in that case what has replaced it? I am quite
>> confused at the moment so if something doesn't make sense I'd be very
>> happy with any kind of explanation that makes me understand again. The
>> following piece of code is what I'm working with at the moment. It
>> compiles but doesn't really cause anything to happen when run.
>>     
>
> gcc4 internals are very different from gcc3 internals.  That's why we
> bumped the version number.  In gcc4, everything is translated into
> GIMPLE, a tree based language, and works from there.
>
> There is no need for EXPR_STMT in GIMPLE, so it was moved to the C++
> frontend which continues to use it when handling templates.
>
> Ian
>   



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-09-07 11:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-05 10:30 code instrumentation in the tree structure Björn Skoglund
2006-09-05 15:32 ` Ian Lance Taylor
2006-09-07 11:19   ` Björn Skoglund

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).