Re: GCC plugin: copying function's arguments

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Well, not sure if it is the right way to go, but I tried creating SSA_NAMEs for the function's arguments and use them in the later assignments rather than the parm_decls themselves.

Now an assert triggers at out-of-ssa phase, at ssaexpand.h:59, in get_rtx_for_ssa_name().

My code changed like this:

-------------
tree var, copy_par;
...

g = gimple_build_nop();
var = make_ssa_name(p, g);
gimple_seq_add_stmt_without_update (&seq, g);

copy_par = create_tmp_var(TREE_TYPE(p), NULL);
add_referenced_var(copy_par);
copy_par = make_ssa_name(copy_par, NULL);
g = gimple_build_assign_with_ops(
  NOP_EXPR, copy_par, var, NULL_TREE);

<the rest is the same as before>
-------------

Because there are no real statements to define these SSA_NAMEs, I added GIMPLE_NOPs for that purpose.

The assert triggers at ssaexpand.h:59, in get_rtx_for_ssa_name():

(gdb) l
53	static inline rtx
54	get_rtx_for_ssa_name (tree exp)
55	{
56	  int p = partition_find (SA.map->var_partition, SSA_NAME_VERSION (exp));
57	  if (SA.map->partition_to_view)
58	    p = SA.map->partition_to_view[p];
59	  gcc_assert (p != NO_PARTITION);
60	  return SA.partition_to_pseudo[p];
61	}

partition_find() returns 19 at line 56 but SA.map->partition_to_view[p] is -1 (NO_PARTITION) in this case, and gcc_assert() fires.

The function being processed is rather simple:

------------------
static void
other_func(const char *p, int x, unsigned long u, unsigned char s,
	unsigned long other[])
{
	printf("x = %d, p = %s, u = %lu, args: %lx, %lx\n",
		x, p, u, other[0], other[1]);
	printf("%lu\n", *(unsigned long *)&s);
}
------------------

When debugging this with GDB, I can see that GCC first processes the SSA_NAMEs for 'p', 'x' and 'u' - no crash, SA.map->partition_to_view[p] is not -1 for these. After that, 's' is processed and this is when the problem happens.

Here is what debug_tree() shows for the SSA_NAME for 's' at that point, if it helps:

------------------
<ssa_name 0xb6fd27bc
type <integer_type 0xb6f621e0 unsigned char public unsigned string-flag QI
        size <integer_cst 0xb6f5071c constant 8>
        unit size <integer_cst 0xb6f50738 constant 1>
align 8 symtab -1224807280 alias set -1 canonical type 0xb6f621e0 precision 8 min <integer_cst 0xb6f50754 0> max <integer_cst 0xb6f506e4 255> context <translation_unit_decl 0xb7002d80 D.1837>
        pointer_to_this <pointer_type 0xb7020f60>>
    var <parm_decl 0xb701cec4 s>def_stmt GIMPLE_NOP

    version 19>
------------------

Any ideas what could possibly be wrong here?

Regards,
Eugene

--
Eugene Shatokhin, ROSA
www.rosalab.com




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux