> Ugh, yeah. I suppose PTA assigned a HEAP var as pointed-to object for the
> original pointer, even if the transformed stmt
>
> orig_ptr_1 = &a;
>
> has the points-to information preserved for orig_ptr_1 further propagation
> of &a will make accesses through orig_ptr_1 have different alias
> properties.
AFAICS it's an escaping problem: the new variable isn't seen as escaping at
some call point. Testcase attached, compile opt22.adb at -O but make sure
your tree is up-to-date.
> What should work in this special case of a singleton points-to set of
> orig_ptr_1 (might want to check that) is, do
>
> SET_DECL_PT_UID (decl-of-a, DECL_UID (pointed-to orig_ptr_1));
>
> The brute force approach is not acceptable (it'll wreck IPA points-to
> info).
OK, thanks for the tip.
2011-09-26 Eric Botcazou <[email protected]>
* gnat.dg/opt22.adb: New test.
* gnat.dg/opt22_pkg.ad[sb]: New helper.
--
Eric Botcazou
-- { dg-do run }
-- { dg-options "-O" }
with Opt22_Pkg; use Opt22_Pkg;
procedure Opt22 is
procedure Go (S : String) is
begin
begin
Fail;
exception
when Constraint_Error => Put ("the " & S);
end;
Put ("the " & S);
end;
begin
Go ("message");
end;
package Opt22_Pkg is
procedure Fail;
procedure Put (S : String);
end Opt22_Pkg;
package body Opt22_Pkg is
procedure Fail is
begin
raise Constraint_Error;
end;
procedure Put (S : String) is
begin
if S /= "the message" then
raise Program_Error;
end if;
end;
end Opt22_Pkg;