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]

[Ada] fix undue pessimization wrt Pure subprograms


Hello,

We rediscussed the Ada language reference manual bits about "pragma
Pure" and decided to revisit the orientation taken in

   http://gcc.gnu.org/ml/gcc-patches/2008-08/msg00029.html

In particular, we are now of the opinion that

  << 18/2 If a library unit is declared pure, then the implementation is
          permitted to omit a call on a library-level subprogram of
          the library unit if the results are not needed after the call.
  >>

allows us to omit a call to a Pure subprogram possibly raising an
exception even if there is an exception handler, as in 

    procedure handle_raise_from_pure is
       K : Integer;
    begin
       K := Raise_CE_If_0 (0);
    exception
       when others => Put_Line ("exception caught");
    end;

This patch re-activates and tidies the code controling this, which
cures a regression in optimization opportunities.

Bootstrapped and regtested on x86_64-suse-linux.

Olivier

	2008-11-13  Olivier Hainque  <hainque@adacore.com>

	ada/
	* gcc-interface/decl.c (gnat_to_gnu_entity) <case E_Function>:
	Turn Ada Pure on subprograms back into GCC CONST when eh constructs
	are explicit to the back-end.  Tidy.

	testsuite/
	* gnat.dg/test_raise_from_pure.adb: Adjust to match revised intent.
	* gnat.dg/wrap_raise_from_pure.ad[bs]: Remove.
	* gnat.dg/handle_raise_from_pure.adb: New test.

Attachment: pure-const.dif
Description: Text document


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