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

Re: [Patch] Fix bogus 'function does return' warning


On Thu, Oct 15, 2009 at 9:48 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
> Hi,
>
> the GIMPLE EH patch introduced a regression for the attached testcase: a
> bogus 'function does return' is now issued.
>
> The problem is that the EH pass turns
>
> ? ? ?D.2142 = &"p.adb"[0];
> ? ? ?.gnat_rcheck_20 (D.2142, 7);
> ? ? ?<D.2137>:
> ? ? ?D.2143 = &"p.adb"[0];
> ? ? ?.gnat_rcheck_04 (D.2143, 9);
> ? ? ?goto <D.2151>;
> ? ?}
> ?finally
> ? ?{
> ? ? ?p.error (); [static-chain: &FRAME.8]
> ? ?}
> ?<D.2151>:
> ?return;
>
> into
>
> ?D.2142 = &"p.adb"[0];
> ?.gnat_rcheck_20 (D.2142, 7);
> ?<D.2137>:
> ?D.2143 = &"p.adb"[0];
> ?.gnat_rcheck_04 (D.2143, 9);
> ?finally_tmp.10 = 0;
> ?goto <D.2156>;
> ?<D.2156>:
> ?p.error (); [static-chain: &FRAME.8]
> ?switch (finally_tmp.10) <default: <D.2159>, default: <D.2159>, case 1:
> <D.2158>>
> ?<D.2159>:
> ?goto <D.2151>;
> ?<D.2151>:
> ?return;
> ?<D.2157>:
> ?finally_tmp.10 = 1;
> ?goto <D.2156>;
> ?<D.2158>:
> ?resx 1
>
> thus masking the fact that D.2159 and D.2151 are unreachable. ?So the CFG ends
> up being
>
> <bb 21>:
> ?D.2143 = &"p.adb"[0];
> ?.gnat_rcheck_04 (D.2143, 9);
>
> <L17>:
> ?return;
>
> <L19>:
> ?finally_tmp.10 = 1;
> ?p.error (); [static-chain: &FRAME.8]
> ?switch (finally_tmp.10) <default: <L17>, case 1: <L20>>
>
> <L20>:
> ?resx 1
>
> and the EXIT block has a predecessor, hence the warning.
>
>
> The proposed fix is to remove unreachable statements after noreturn calls
> during the "lower" pass. ?Tested on i586-suse-linux, OK for mainline?

Huh.  I wonder why the unreachable blocks are not removed
after CFG build?  After all noreturn calls end BBs.

Am I missing sth?

Richard.

>
> 2009-10-15 ?Eric Botcazou ?<ebotcazou@adacore.com>
>
> ? ? ? ?* gimple-low.c (lower_stmt) <GIMPLE_CALL>: If the call is noreturn,
> ? ? ? ?remove subsequent regular statements in the sequence.
>
>
> 2009-10-15 ?Eric Botcazou ?<ebotcazou@adacore.com>
>
> ? ? ? ?* gnat.dg/noreturn1.ad[sb]: New test.
>
>
> --
> Eric Botcazou
>


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