This is the mail archive of the gcc-help@gcc.gnu.org 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]

Help with GHDL : GCC fails during -O2 optimisation passes.


Hi,

I'm trying to get ghdl to build against gcc4.8.2. I seem to have a
regression over gcc4.7 and I'm looking for some pointers to fix it.

ghdl is a VHDL compiler front end for gcc, producing gimple code and
passing it to the gcc middle and back ends to generate an executable. To
simulate a VHDL design, just run the executable.

It had lagged behind for a couple of years until I brought it up to date
for gcc4.7, and it's time to do the same with 4.8.

Now it builds with gcc4.8.2, and the resulting executable runs and
produces the correct results : until I turn on optimisation for example
-O2. Then:
------------------------------------------------
 ghdl -a -O2 test_utils.vhd
test_utils.vhd: In function âwork__test_utils__ARCH__thing__to_hexâ:
test_utils.vhd:1:0: internal compiler error: Segmentation fault
 ENTITY Test_utils IS
 ^
0x5314cf crash_signal
    /home/brian/Projects/gcc4.8.2/source/gcc-4.8.2/gcc/toplev.c:332
0x7c0934 gimple_build_call(tree_node*, unsigned int, ...)
    /home/brian/Projects/gcc4.8.2/source/gcc-4.8.2/gcc/gimple.c:248
0xddaa4f unloop_loops(bitmap_head_def*, bool*)
    /home/brian/Projects/gcc4.8.2/source/gcc-4.8.2/gcc/tree-ssa-loop-ivcanon.c:623
0xddb0d7 tree_unroll_loops_completely(bool, bool)
    /home/brian/Projects/gcc4.8.2/source/gcc-4.8.2/gcc/tree-ssa-loop-ivcanon.c:1199
0xa5b2b2 tree_complete_unroll_inner
    /home/brian/Projects/gcc4.8.2/source/gcc-4.8.2/gcc/tree-ssa-loop.c:511
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
------------------------------------------------

The problem appears to stem from the (bitvector) array assignment in the
testcase below, which translates to the call to __ghdl_memcopy in the
gimple code (further below). 
Commenting out that call in GHDL's own internal format, the compile
succeeded, with only that call missing from the gimple.

I hope it's OK to present the whole gimple file : it's not huge.

Now I don't know the next steps to take:

I'm hoping perhaps somebody can advise me there's something visibly
wrong in the gimple : Not the fact that it initialises a local copy then
memcpy's to the destination; that's merely inefficient; but something
that might call the tree-ssa passes to fail.

Or perhaps someone may recall changes to the tree-ssa passes that
required front end changes, not yet backported to ghdl.

Or I could do with advice on how to work with gcc internals, to get more
diagnostics out of it. I have read a lot of
http://gcc.gnu.org/onlinedocs/gccint and it's helpful but I don't know
of anything that says "to debug these opt passes, configure with this
option" etc.

Or even, is there a way to source the gimple dump from one pass back
into the next pass, and dump that, until something obviously goes wrong?

So ... any ideas?

Thanks for any help you can give.

- Brian
------------------------------------------------

------------------------------------------------
ENTITY Test_utils IS
END Test_utils;

ARCHITECTURE thing OF Test_utils IS

procedure to_hex  is
    variable b_arr : bit_vector(3 downto 0);
begin
       b_arr := (others => '0');
end to_hex;

begin
END thing;
------------------------------------------------
testbench__test_utils__ELAB (struct testbench__test_utils__INSTTYPE *
INSTANCE)
{

}


testbench__test_utils__ARCH__thing__to_hex (struct
testbench__test_utils__ARCH__thing__INSTTYPE * INSTANCE)
{
  typedef std__standard__bit
testbench__test_utils__ARCH__thing__to_hex__b_arr__OT[4];
  static struct std__standard__bit_vector__BOUND
testbench__test_utils__ARCH__thing__to_hex__b_arr__OT__STB =
{.dim_1={.left=3, .right=0, .dir=1, .length=4}};
  std__standard__bit b_arr[4];

  try
    {
      {
        __ghdl_index_type T2_0;

        T2_0 = 0;
        <D.1013>:
        if (T2_0 == 4) goto <D.1021>; else goto <D.1022>;
        <D.1021>:
        goto <D.1014>;
        <D.1022>:
        b_arr[T2_0] = 0;
        T2_0 = T2_0 + 1;
        goto <D.1013>;
        <D.1014>:
      }
      {
        std__standard__bit T0_0[4];

        try
          {
            {
              __ghdl_index_type T1_0;
              __ghdl_index_type T1_1;

              T1_0 = 4;
              T1_1 = 0;
              <D.1018>:
              if (T1_1 == T1_0) goto <D.1023>; else goto <D.1024>;
              <D.1023>:
              goto <D.1019>;
              <D.1024>:
              T0_0[T1_1] = 0;
              T1_1 = T1_1 + 1;
              goto <D.1018>;
              <D.1019>:
            }
            __ghdl_memcpy (&b_arr, &T0_0, 4);
          }
        finally
          {
            T0_0 = {CLOBBER};
          }
      }
    }
  finally
    {
      b_arr = {CLOBBER};
    }
}


testbench__test_utils__ARCH__thing__ELAB (struct
testbench__test_utils__INSTTYPE * INSTANCE)
{
  struct testbench__test_utils__ARCH__thing__INSTTYPE * ARCH_INSTANCE;

  ARCH_INSTANCE = INSTANCE;
  INSTANCE->RTI.rti = &testbench__test_utils__ARCH__thing__RTI;
  testbench__test_utils__ELAB (INSTANCE);
}
------------------------------------------------




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