> back in January in
> http://gcc.gnu.org/ml/gcc-patches/2014-01/msg00848.html Eric pointed
> out a testcase where the problem was SRA not scalarizing an aggregate
> because it was involved in a throwing statement. The reason is that
> SRA is likely to need to append new statements after each one where a
> replaced aggregate is present, but throwing statements must end their
> BBs. This patch comes up with a fix for most such situations by
> adding these new statements onto a single successor non-EH edge, if
> there is one and only one such edge.
Thanks for working on this.
> I have bootstrapped and tested a very similar version on x86_64-linux,
> bootstrap and testing of this exact one is currently underway. OK for
> trunk? Eric, if and once this gets in, can you please add the
> testcase from your original post to the suite?
Reduced testcase attached, you can install it with the patch.
* gnat.dg/opt34.adb: New test.
* gnat.dg/opt34_pkg.ads: New helper.
--
Eric Botcazou
-- { dg-do compile }
-- { dg-options "-O -fdump-tree-esra" }
with Opt34_Pkg; use Opt34_Pkg;
procedure Opt34 is
function Local_Fun (Arg : T_Private) return T_Private is
Result : T_Private;
begin
case Get_Integer (Arg) is
when 1 =>
Result := Get_Private (100);
when 2 =>
Result := T_Private_Zero;
when others =>
null;
end case;
return Result;
end Local_Fun;
begin
Assert (Get_Integer (Local_Fun (Get_Private (1))) = 100);
end;
-- { dg-final { scan-tree-dump "Created a replacement for result" "esra" } }
-- { dg-final { cleanup-tree-dump "esra" } }
package Opt34_Pkg is
type T_Private is record
I : Integer := 0;
end record;
T_Private_Zero : constant T_Private := (I => 0);
function Get_Private (I : Integer) return T_Private;
function Get_Integer (X : T_Private) return Integer;
procedure Assert (Cond : Boolean);
end Opt34_Pkg;