From: Daniel Berlin <[EMAIL PROTECTED]>
To: sean yang <[EMAIL PROTECTED]>
CC: gcc@gcc.gnu.org
Subject: Re: adding nodes in a tree --after GIMPLIFICATION, before SSA
Date: Wed, 19 Apr 2006 22:38:11 -0700

In fact, there are only *two* places a call can occur in GIMPLE at that point: bare, or the RHS of a MODIFY_EXPR.

The following code will give you *all* the CALL_EXPR statements in a function.


block_stmt_iterator bsi;
basic_block bb;

FOR_EACH_BB (bb)
{
  for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
  {
    tree stmt = bsi_stmt (bsi);
    if (TREE_CODE (stmt) == CALL_EXPR
|| (TREE_CODE (stmt) == MODIFY_EXPR && TREE_CODE (TREE_OPERAND (stmt, 1) == CALL_EXPR))
     {
/* Do your thing, make sure to use BSI_SAME flags so that iteration will move properly. */
     }
  }
}

How can we get the rule of name mangling in GCC frontend?
For example, the sysbol name for foo in C is still "foo", but the sysmbol name for foo in C++ (output of g++) is something like "_Z3foov". Futhermore, symbol name foo in fortran is "_foo".


If I want to instrument mpi calls in a program, the three languages synopsis (c, c++, fortran) are different.
e.g. mpi_bsend has three interface:
C++:  void MPI::Comm::Bsend; C: MPI_Bsend; Fortran: MPI_BSEND

I want to insert the instrumentation code no matter from what language the MPI subroutines are called. I think I can take care of C and Fortran by the following (psuedo) code, but how can i find the rule for c++ name mangling? are there many cases that I need take care of?

if (TREE_CODE ( t ) == FUNCTION_DECL){

if (( !strncmp (IDENTIFIER_POINTER(DECL_NAME (t) , "mpi_", 4) || ( !strncmp (IDENTIFIER_POINTER(DECL_NAME (t) , "_mpi_", 5)) {
    //(1) handles case of C language; (2) handle the case of Fortran
}

}

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

Reply via email to