How to know the DEF operand that corresponds to a specific argument of a call to function?
Daniel Berlin
dberlin@dberlin.org
Thu May 19 17:12:00 GMT 2005
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
More information about the Gcc
mailing list