This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: How to know the DEF operand that corresponds to a specificargument of a call to function?
- From: Daniel Berlin <dberlin at dberlin dot org>
- To: Davide Pozza <davide dot pozza77 at gmail dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 19 May 2005 11:45:27 -0400
- Subject: Re: How to know the DEF operand that corresponds to a specificargument of a call to function?
- References: <f76aa85605051907424a2672df@mail.gmail.com>
On Thu, 2005-05-19 at 16:42 +0200, Davide Pozza wrote:
> I'd need some help to develop a function, for a new gcc pass,
> located after the value range propagation pass.
>
> I'm working on the last release of gcc 4.1.
>
> I'd like to have a function that receiving a stmt (that is
> a CALL_EXPR) and an index (to specify the position of the
> argument), has to return, for the argument specified, the variable
> "defined" (i.e. the variable between those obtainable by code like
> "FOR_EACH_SSA_TREE_OPERAND (def, ..., stmt, SSA_OP_ALL_DEFS)" ).
> The function has to return a NULL_TREE, when there is not a
> definition for the given argument.
>
> The function prototype should be:
> static tree get_def_operand(tree stmt, int i);
>
>
> To explain me better, I use an example.
>
> Supposing to have an fgets call.
>
> # stdin_12 = V_MAY_DEF <stdin_1>;
> # buf_13 = V_MAY_DEF <buf_3>;
> # dst_14 = V_MAY_DEF <dst_11>;
> [test.c : 10] fgets (&buf, 10, stdin.23_2);
>
> Calling the get_def_operand for this statement with index 0, the
> function has to return the tree corresponding to buf_13.
Uh, don't you mean buf?
Or are you trying to match up call arguments with V_MAY_DEF's (if so,
you are out of luck, you'll have to do it somewhat like
get_call_expr_operands does it, which is to walk each real argument of
the call, and see what the associated memory tag is)
>
> Thanks for the attention!
>
> Davide