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


TREE_ADDRESSABLE flag

2008-04-09 Thread Dasarath Weeratunge
I came across the following problem when trying to instrument the program.

If I take the address of trees using build_fold_addr_expr at O2 the
compiled programs
crash (segmentation fault) at runtime. They run OK at O0. In this
particular case I only took
the addresses of var_decl and parm_decl nodes. What optimization could
I be interfering with?

In fact I did not perform instrumentation for I noticed that the
moment build_fold_addr_expr is
called and it set the TREE_ADDRESSABLE flag the program would crash.

thanks.
-- dasarath


gimple

2008-03-27 Thread Dasarath Weeratunge
Is it possible to map simplified source statements back to the
original source code in GCC?

If this is not possible is it possible to stop the simplification
altogether and just retain the original
source tree in say DECL_SAVED_TREE(...) ? I tried removing tree
lowering passes but gcc still
seems to simplify the source.

My analysis computes program slices and I prefer if it outputs
original source code.

thanks,
-- dasarath


GCC build problem

2008-03-05 Thread Dasarath Weeratunge
I added a field to struct basic_block_def in basic-block.h of type
struct pointer_set_t.

Now when I try to rebuild GCC build fails with error:

libbackend.a(gtype-desc.o): In function `gt_pch_nx_basic_block_def':
/scratch/dweeratu/gcc/build/gcc/gtype-desc.c:2472: undefined reference
to `gt_pch_nx_pointer_set_t'
/scratch/dweeratu/gcc/build/gcc/gtype-desc.c:2473: undefined reference
to `gt_pch_nx_pointer_set_t'
libbackend.a(gtype-desc.o): In function `gt_ggc_mx_basic_block_def':
/scratch/dweeratu/gcc/build/gcc/gtype-desc.c:708: undefined reference
to `gt_ggc_mx_pointer_set_t'
/scratch/dweeratu/gcc/build/gcc/gtype-desc.c:709: undefined reference
to `gt_ggc_mx_pointer_set_t'
collect2: ld returned 1 exit status

It looks as if some auto generated files are not been regenerated
properly. This happens
even if I completely redo the build.

How can this be fixed?

thanks,
-- dasarath


global declarations

2008-02-25 Thread Dasarath Weeratunge
Once the files have been completely parsed, how can I traverse through
all global declarations (e.g. types and variables) ? I can find the
functions by traversing the call graph but would like to know how to
do the same for types and variables. Also is there a way to find a
decl from its UID?

Thanks.
-- dasarath


call site information

2008-02-21 Thread Dasarath Weeratunge
If I have a CALL_EXPR how can I find out information about the call
site? For example, the filename and line number.

thanks,
-- dasarath


cc1

2008-02-16 Thread Dasarath Weeratunge
When I use cc1 directly it outputs a whole lot of text like:

 gnu_dev_major gnu_dev_minor gnu_dev_makedev stat lstat fstat fstatat
mknod mknodat stat64 lstat64 fstat64 fstatat64 shwi_to_double_int
uhwi_to_double_int double_int_zero_p double_int_one_p
double_int_minus_one_p double_int_equal_p
VEC_tree_must_be_pointer_type VEC_tree_base_length VEC_tree_base_last
VEC_tree_base_index VEC_tree_base_iterate VEC_tree_base_

is there an option to surpress this?

thanks,
-- dasarath


compilation flow

2008-02-15 Thread Dasarath Weeratunge
I'm trying to extract the C front end of GCC with all tree lowering
passes, and call graph generation. I do not need ssa conversion. Is
tree_rest_of_compilation the correct place to cut the compiler
pipeline for this?

thanks,
-- dasarath


GCC ssa and alias info

2008-02-12 Thread Dasarath Weeratunge
Is it possible to dump the ssa representation and alias information
generated by the compiler to a file?

thanks,
-- dasarath