This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Parameter not passed in call expr
- From: Dodji Seketeli <dodji at seketeli dot org>
- To: ludovic dot courtes at inria dot fr (Ludovic CourtÃs)
- Cc: gcc at gcc dot gnu dot org
- Date: Sat, 09 Apr 2011 13:12:38 +0200
- Subject: Re: Parameter not passed in call expr
- References: <87mxk115q5.fsf@inria.fr>
Hello Ludovic,
ludovic.courtes@inria.fr (Ludovic CourtÃs) a Ãcrit:
> The attached plug-in builds a function like this:
>
> my_function (void * parm.0)
> {
> __builtin_puts (parm.0);
> }
>
> However, the generated assembly clears the first-argument register
> (%edi) before calling âputsâ, instead of actually passing the parameter:
>
> my_function:
> .LFB0:
> .file 1 "tt.c"
> .loc 1 1 0
> .cfi_startproc
> .loc 1 1 0
> xorl %edi, %edi ;; %edi shouldnât be cleared
> jmp puts
> .cfi_endproc
>
> Any idea what Iâm doing wrong?
[...]
> static void
> define_function (void *gcc_data, void *user_data)
> {
> tree decl, void_ptr;
> location_t loc = input_location;
>
> void_ptr = build_pointer_type (void_type_node);
> decl = build_decl (loc, FUNCTION_DECL, get_identifier ("my_function"),
> build_function_type_list (void_type_node,
> void_ptr, NULL_TREE));
>
> tree parm;
> parm = build_decl (loc, PARM_DECL,
> create_tmp_var_name ("parm"),
> void_ptr);
It looks like a:
DECL_ARG_TYPE (parm) = void_ptr;
might be helpful here.
> DECL_CONTEXT (parm) = decl;
> TREE_USED (parm) = true;
> DECL_ARGUMENTS (decl) = parm;
[...]
--
Dodji