This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Parameter not passed in call expr


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]