Hello Ludovic, ludovic.cour...@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