Re: address taken problem

2008-04-11 Thread Jim Wilson

Dasarath Weeratunge wrote:

In the following code I marked the tree 'node.0' as address taken using
'c_mark_addressable'. Now in the assembly code, isn't the return value of the
second call to malloc completely discarded?


c_mark_addressable is meant to be called during parsing.  It may affect 
the IL that will be generated, so you can't expect to be able to call it 
during optimization.


You haven't given us a copy of your patch, or the C code for your 
testcase.  It is difficult to say much definitive when we are lacking 
detailed info about what you are doing.


Jim


address taken problem

2008-04-10 Thread Dasarath Weeratunge
In the following code I marked the tree 'node.0' as address taken using
'c_mark_addressable'. Now in the assembly code, isn't the return value of the
second call to malloc completely discarded?

This problem does not arise in -O0. Here I'm using -O2.


main ()
{
  void * D.2897;
  struct node * D.2898;
  struct node * node.0;
  void * D.2900;
  int * D.2901;
  int * D.2902;
  struct node * node;

  D.2897 = malloc (8);
  D.2898 = (struct node *) D.2897;
  node = D.2898;
  node.0 = node;
  D.2900 = malloc (4);
  D.2901 = (int *) D.2900;
  node.0->item = D.2901;<--
  node.0 = node;
  D.2902 = node.0->item;
  printf (&"%p %p\n"[0], D.2902, &node);
}


main:
.LFB5:
  subq  $24, %rsp
.LCFI0:
  movl  $8, %edi
  call  malloc
  movl  $4, %edi
  movq  %rax, 16(%rsp)
  call  malloc
  movq  16(%rsp), %rax
  leaq  16(%rsp), %rdx
  movl  $.LC0, %edi
  movq  (%rax), %rsi
  xorl  %eax, %eax
  call  printf
  addq  $24, %rsp
  ret


The code that is generated when I do not modify the flag.

main:
.LFB5:
  pushq %rbx
.LCFI0:
  movl  $8, %edi
  subq  $16, %rsp
.LCFI1:
  call  malloc
  movl  $4, %edi
  movq  %rax, %rbx
  movq  %rax, 8(%rsp)
  call  malloc
  movq  %rax, (%rbx)
  movq  8(%rsp), %rax
  leaq  8(%rsp), %rdx
  movl  $.LC0, %edi
  movq  (%rax), %rsi
  xorl  %eax, %eax
  call  printf
  addq  $16, %rsp
  popq  %rbx
  ret


thanks,
-- dasarath