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

Flow analysis confused by exception handling


The problem I sent few days ago about register being clobbered
in sparc while throwing seems to be actually flow analysis problem.
In the following code, the initial assignment to `i' gets deleted
because the next instruction also assigns it.

The rtl dump after the second cse looks like:

(insn 11 8 13 (set (reg/v:SI 105)
        (const_int 0)) 111 {*movsi_insn} (nil)
    (expr_list:REG_EQUAL (const_int 0)
        (nil)))

(note 13 11 15 13 NOTE_INSN_EH_REGION_BEG)

(note 15 13 17 "" NOTE_INSN_DELETED)

(note 17 15 19 "" NOTE_INSN_DELETED)

(call_insn 19 17 21 (parallel[ 
            (set (reg:SI 8 %o0)
                (call (mem:SI (symbol_ref:SI ("bar__Fv")))
                    (const_int 0)))
            (clobber (reg:SI 15 %o7))
        ] ) -1 (nil)
    (nil)
    (nil))

But after the flow analysis, the assignment to zero is gone:

(note 8 7 11 "" NOTE_INSN_DELETED)

;; Start of basic block 0, registers live: 14 [%sp] 30 [%fp] 31 [%i7]
(note 11 8 13 "" NOTE_INSN_DELETED)

(note 13 11 15 13 NOTE_INSN_EH_REGION_BEG)

(note 15 13 17 "" NOTE_INSN_DELETED)

(note 17 15 19 "" NOTE_INSN_DELETED)

(call_insn 19 17 21 (parallel[ 
            (set (reg:SI 8 %o0)
                (call (mem:SI (symbol_ref:SI ("bar__Fv")))
                    (const_int 0)))
            (clobber (reg:SI 15 %o7))
        ] ) -1 (nil)
    (expr_list:REG_UNUSED (reg:SI 15 %o7)
        (nil))
    (nil))

This would be right if bar wouldn't throw anything, but it is
clearly wrong because insn 19 does not actually assign anything.

Teemu

---------------------------------------------------------------------------
#include <stdio.h>

int bar ()
{
  throw 100;
}

main ()
{
  int i = 0;			// this gets deleted after flow analysis
  try
    {
      i = bar ();
    }
  catch (...)
    {
    }

  printf ("i = %d\n", i);
  return i;
}
---------------------------------------------------------------------------


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