Hi Diego,

Diego Novillo wrote:
> Yoav Etsion wrote:
>
>
>>The problem is that the first mudflap pass takes place at the GIMPLE
>>level, at which point all variables have their
>>addressable/non-addressable attributes set, which forbids me to build an
>>ADDR_EXPR node for a non-addressable pointer variable ("invalid operand
>>to unary & operator" error).
>>
>
> Call build_addr() to create the ADDR_EXPR.  It will set the
> TREE_ADDRESSABLE bit on the variable and set some attributes on the
> ADDR_EXPR itself.
>
The code is nicer, but still no go... :)

>
> That message suggest that you may be trying to build the address of a
> non-decl, though. Show me the code and an example of your transformation?
>

The transformation is simple: mudflap already injects a call to __mf_register when an addressable variable is declared. I want to do the same for all pointer variables, so I've added the predicate
POINTER_TYPE_P( TREE_TYPE(decl) )
to the eligibility test (performed on each VAR_DECL node).
gcc is compiled with --enable-checking.

The test code:
>>>
/* avoid including the entire header. */
extern int printf (const char * __format, ...);

int main()
{
   int data = 15;
   int *data_p = &data;

   printf("%d, %d\n", (int)data_p, data);

   return 0;
}
<<<

The code dump after the first mudflap pass is:
>>>
{
  intD.0 data.0D.781;
  intD.0 data_p.1D.782;
  intD.0 D.783;
  intD.0 dataD.779;
  intD.0 * data_pD.780;

  try
    {
__mf_register (&dataD.779, 4, 3, "simple-stack-pointer.c:6 (main) data"); __mf_register (&data_pD.780, 4, 3, "simple-stack-pointer.c:7 (main) data_p");
      dataD.779 = 15;
      data_pD.780 = &dataD.779;
      data.0D.781 = dataD.779;
      data_p.1D.782 = (intD.0) data_pD.780;
      printf (&"%d, %d\n"[0], data_p.1D.782, data.0D.781);
      D.783 = 0;
      return D.783;
    }
  finally
    {
      __mf_unregister (&dataD.779, 4, 3);
      __mf_unregister (&data_pD.780, 4, 3);
    }
}
<<<

The exact error message is:
>>>
simple-stack-pointer.c: In function 'main':
simple-stack-pointer.c:5: error: Invalid operand to unary operator
data_pD.780

simple-stack-pointer.c:5: internal compiler error: verify_stmts failed.
please submit...
<<<

The error message directs me to the addressability of 'data_p'.
Any ideas?

Thanks,

Yoav Etsion

Reply via email to