From mboxrd@z Thu Jan 1 00:00:00 1970 From: Teemu Torma To: egcs@cygnus.com Subject: Flow analysis confused by exception handling Date: Tue, 02 Dec 1997 01:47:00 -0000 Message-id: <199712020947.KAA05490@lev.labs.trema.com> X-SW-Source: 1997-12/msg00077.html 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 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; } ---------------------------------------------------------------------------