This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

valreg at calls.c is 0 at a moment


I always try not to disturb this mailing list with my idiot questions.
But I'm suffering huge lack of my knowledge about GCC.

I'm trying to port gcc to my own processor. I compiled gcc(make
all-gcc) and newlib. then i come back to gcc compiling libgcc. However
i got Segmentation fault while compiling unwind-dw2-fde.c . the error
message is below.

../../../../sdk/gcc-4.3.3/libgcc/../gcc/unwind-dw2-fde.c: In function
../../../../sdk/gcc-4.3.3/libgcc/../gcc/unwind-dw2-fde.c:157: internal
compiler error: Segmentation Fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <> for instructions.
make[2]: *** [unwind-dw2-fde.o] Error 1

the code occuring error is assignment of malloc function.
__register_frame_table (void *begin)
  struct object *ob = malloc (sizeof (struct object));
  __register_frame_info_table (begin, ob);
then i tried to find out what is the problem. So i use gdb and then backtrace.

 <visibility> <early_local_cleanups> <inline> <static-var>
<pure-const>Assembling functions:
 __register_frame_info_bases __register_frame_info
__register_frame_info_table_bases __register_frame_info_table
fde_unencoded_compare frame_downheap frame_heapsort
size_of_encoded_value base_from_object read_encoded_value_with_base
get_cie_encoding classify_object_over_fdes add_fdes
fde_single_encoding_compare fde_mixed_encoding_compare
linear_search_fdes __register_frame_table
Program received signal SIGSEGV, Segmentation fault.
0x080ce95d in expand_call (exp=0xb7966750, target=0x0, ignore=0) at
2880              rtx temp = gen_reg_rtx (GET_MODE (valreg));
(gdb) bt
#0  0x080ce95d in expand_call (exp=0xb7966750, target=0x0, ignore=0)
at ../../../sdk/gcc-4.3.3/gcc/calls.c:2880
#1  0x080c34d3 in expand_builtin (exp=0xb7966750, target=0xb7755360,
subtarget=0x0, mode=SImode, ignore=0) at
#2  0x0813f970 in expand_expr_real_1 (exp=0xb7966750,
target=0xb7755360, tmode=SImode, modifier=EXPAND_NORMAL,
alt_rtl=0xbfdfc49c) at ../../../sdk/gcc-4.3.3/gcc/expr.c:8069
#3  0x08144992 in expand_expr_real (exp=0xb7966750, target=0xb7755360,
tmode=SImode, modifier=EXPAND_NORMAL, alt_rtl=0xbfdfc49c) at
#4  0x0814a1fd in store_expr (exp=0xb7966750, target=0xb7755360,
call_param_p=0, nontemporal=0 '\0') at
#5  0x0813df80 in expand_assignment (to=0xb796b528, from=0xb7966750,
nontemporal=1 '\001') at ../../../sdk/gcc-4.3.3/gcc/expr.c:4367
#6  0x08140bee in expand_expr_real_1 (exp=0xb7965e1c, target=0x0,
tmode=VOIDmode, modifier=EXPAND_NORMAL, alt_rtl=0x0) at
#7  0x08144992 in expand_expr_real (exp=0xb7965e1c, target=0xb7989200,
tmode=VOIDmode, modifier=EXPAND_NORMAL, alt_rtl=0x0) at
#8  0x0823811b in expand_expr_stmt (exp=0xb7965e1c) at
#9  0x0839bd97 in expand_gimple_basic_block (bb=0xb77d1d20) at
#10 0x0839ca99 in tree_expand_cfg () at
#11 0x081ce747 in execute_one_pass (pass=0x84f5d00) at
#12 0x081ce8f7 in execute_pass_list (pass=0x84f5d00) at
#13 0x0827829a in tree_rest_of_compilation (fndecl=0xb7949a80) at
#14 0x08360df8 in cgraph_expand_function (node=0xb7962580) at
#15 0x0836276f in cgraph_optimize () at
#16 0x0805946c in c_write_global_declarations () at
#17 0x08244481 in toplev_main (argc=45, argv=0xbfdfc994) at
#18 0x080a8742 in main (argc=Cannot access memory at address 0x0
) at ../../../sdk/gcc-4.3.3/gcc/main.c:35

So, the error occurs at calls.c:2880. which code is..

      if (pass && (flags & ECF_LIBCALL_BLOCK))
+---- 60 : {---------------------------------------------------------------------
      else if (pass && (flags & ECF_MALLOC))
      rtx temp = gen_reg_rtx (GET_MODE (valreg));
      rtx last, insns;

at this statement, valreg was 0 when i printed that value. i wondered
why valreg is 0. most assignment of valreg is determined by
structure_value_addr, which is non-zero at this time. It means that
'malloc' returns BLKmode value. isn't it?

actually, you can see that the target parameter is changed to 0 at
expand_calls. the position is calls.c:2094

    struct_value_size = int_size_in_bytes (TREE_TYPE (exp));

    if (target && MEM_P (target) && CALL_EXPR_RETURN_SLOT_OPT (exp))
      structure_value_addr = XEXP (target, 0);
        /* For variable-sized objects, we must be called with a target
           specified.  If we were to allocate space on the stack here,
           we would have no way of knowing when to free it.  */
        rtx d = assign_temp (TREE_TYPE (exp), 0, 1, 1);

        mark_temp_addr_taken (d);
        structure_value_addr = XEXP (d, 0);
        target = 0;

in this block, structure_value_addr and target is changed.

This is all I found from yesterday. And I can not go further. I am
sure that i mistake at target.h. But i changed many defines in
target.h, i couldn't solve this problem.

Does anyone know?

Thank you.

--- Eunchan

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]