aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gnat.dg
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2022-04-07 14:07:54 +0200
committerRichard Biener <rguenther@suse.de>2022-04-07 15:03:36 +0200
commit8c0ebaf9f586100920a3c0849fb10e9985d7ae58 (patch)
tree6d15d0cf669d155035d261647744f8eadb7a8d72 /gcc/testsuite/gnat.dg
parent88b939b19ab454ab2d932ef292bbc557abe4431c (diff)
downloadgcc-8c0ebaf9f586100920a3c0849fb10e9985d7ae58.zip
gcc-8c0ebaf9f586100920a3c0849fb10e9985d7ae58.tar.gz
gcc-8c0ebaf9f586100920a3c0849fb10e9985d7ae58.tar.bz2
ipa/104303 - miscompilation of gnatmake
Modref attempts to track memory accesses relative to the base pointers which are parameters of functions. If it fails, it still makes difference between unknown memory access and global memory access. The second makes it possible to disambiguate with memory that is not accessible from outside world (i.e. everything that does not escape from the caller function). This is useful so we do not punt when unknown function is called. The added ref_may_access_global_memory_p ends up using ptr_deref_may_alias_global_p which does not consider escaped automatic variables as global. For modref those are still global since they can be accessed from functions called. The following adds a flag to the *_global_p APIs indicating whether escaped local memory should be considered as global or not and removes ref_may_access_global_memory_p in favor of using ref_may_alias_global_p with the flag set to true. 2022-04-07 Richard Biener <rguenther@suse.de> Jan Hubicka <hubicka@ucw.cz> PR ipa/104303 * tree-ssa-alias.h (ptr_deref_may_alias_global_p, ref_may_alias_global_p, ref_may_alias_global_p, stmt_may_clobber_global_p, pt_solution_includes_global): Add bool parameters indicating whether escaped locals should be considered global. * tree-ssa-structalias.cc (pt_solution_includes_global): When the new escaped_nonlocal_p flag is true also consider pt->vars_contains_escaped. * tree-ssa-alias.cc (ptr_deref_may_alias_global_p): Pass down new escaped_nonlocal_p flag. (ref_may_alias_global_p): Likewise. (stmt_may_clobber_global_p): Likewise. (ref_may_alias_global_p_1): Likewise. For decls also query the escaped solution if true. (ref_may_access_global_memory_p): Remove. (modref_may_conflict): Use ref_may_alias_global_p with escaped locals considered global. (ref_maybe_used_by_stmt_p): Adjust. * ipa-fnsummary.cc (points_to_local_or_readonly_memory_p): Likewise. * tree-ssa-dse.cc (dse_classify_store): Likewise. * trans-mem.cc (thread_private_new_memory): Likewise, but consider escaped locals global. * tree-ssa-dce.cc (mark_stmt_if_obviously_necessary): Likewise. * gnat.dg/concat5.adb: New. * gnat.dg/concat5_pkg1.adb: Likewise. * gnat.dg/concat5_pkg1.ads: Likewise. * gnat.dg/concat5_pkg2.adb: Likewise. * gnat.dg/concat5_pkg2.ads: Likewise.
Diffstat (limited to 'gcc/testsuite/gnat.dg')
-rw-r--r--gcc/testsuite/gnat.dg/concat5.adb9
-rw-r--r--gcc/testsuite/gnat.dg/concat5_pkg1.adb18
-rw-r--r--gcc/testsuite/gnat.dg/concat5_pkg1.ads5
-rw-r--r--gcc/testsuite/gnat.dg/concat5_pkg2.adb10
-rw-r--r--gcc/testsuite/gnat.dg/concat5_pkg2.ads5
5 files changed, 47 insertions, 0 deletions
diff --git a/gcc/testsuite/gnat.dg/concat5.adb b/gcc/testsuite/gnat.dg/concat5.adb
new file mode 100644
index 0000000..fabf248
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/concat5.adb
@@ -0,0 +1,9 @@
+-- { dg-do run }
+-- { dg-options "-O" }
+
+with Concat5_Pkg1; use Concat5_Pkg1;
+
+procedure Concat5 is
+begin
+ Scan ("-RTS=none");
+end;
diff --git a/gcc/testsuite/gnat.dg/concat5_pkg1.adb b/gcc/testsuite/gnat.dg/concat5_pkg1.adb
new file mode 100644
index 0000000..c32f5af
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/concat5_pkg1.adb
@@ -0,0 +1,18 @@
+with Concat5_Pkg2; use Concat5_Pkg2;
+
+package body Concat5_Pkg1 is
+
+ procedure Make_Failed (S : String);
+ pragma No_Inline (Make_Failed);
+
+ procedure Make_Failed (S : String) is
+ begin
+ Compare (S);
+ end;
+
+ procedure Scan (S : String) is
+ begin
+ Make_Failed ("option " & S & " should start with '--'");
+ end;
+
+end Concat5_Pkg1;
diff --git a/gcc/testsuite/gnat.dg/concat5_pkg1.ads b/gcc/testsuite/gnat.dg/concat5_pkg1.ads
new file mode 100644
index 0000000..7f46d87
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/concat5_pkg1.ads
@@ -0,0 +1,5 @@
+package Concat5_Pkg1 is
+
+ procedure Scan (S : String);
+
+end Concat5_Pkg1;
diff --git a/gcc/testsuite/gnat.dg/concat5_pkg2.adb b/gcc/testsuite/gnat.dg/concat5_pkg2.adb
new file mode 100644
index 0000000..98bd388
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/concat5_pkg2.adb
@@ -0,0 +1,10 @@
+package body Concat5_Pkg2 is
+
+ procedure Compare (S : String) is
+ begin
+ if S /= "option -RTS=none should start with '--'" then
+ raise Program_Error;
+ end if;
+ end;
+
+end Concat5_Pkg2;
diff --git a/gcc/testsuite/gnat.dg/concat5_pkg2.ads b/gcc/testsuite/gnat.dg/concat5_pkg2.ads
new file mode 100644
index 0000000..2931ffd
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/concat5_pkg2.ads
@@ -0,0 +1,5 @@
+package Concat5_Pkg2 is
+
+ procedure Compare (S : String);
+
+end Concat5_Pkg2;