aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2025-02-28 11:44:26 +0100
committerRichard Biener <rguenth@gcc.gnu.org>2025-02-28 13:37:54 +0100
commite6037af6d5e5a43c437257580d75bc8b35a6dcfd (patch)
treebd28690d87ddd3ba7a93fbcc567575885843db23 /gcc
parent26e4783c707a96ebb42c6ec4537578e635974573 (diff)
downloadgcc-e6037af6d5e5a43c437257580d75bc8b35a6dcfd.zip
gcc-e6037af6d5e5a43c437257580d75bc8b35a6dcfd.tar.gz
gcc-e6037af6d5e5a43c437257580d75bc8b35a6dcfd.tar.bz2
ipa/111245 - bogus modref analysis for store in call that might throw
We currently record a kill for *x_4(D) = always_throws (); because we consider the store always executing since the appropriate check for whether the stmt could throw is guarded by !cfun->can_throw_non_call_exceptions. PR ipa/111245 * ipa-modref.cc (modref_access_analysis::analyze_store): Do not guard the check of whether the stmt could throw by cfun->can_throw_non_call_exceptions. * g++.dg/torture/pr111245.C: New testcase.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ipa-modref.cc3
-rw-r--r--gcc/testsuite/g++.dg/torture/pr111245.C23
2 files changed, 24 insertions, 2 deletions
diff --git a/gcc/ipa-modref.cc b/gcc/ipa-modref.cc
index f1d88ab..d3e5101 100644
--- a/gcc/ipa-modref.cc
+++ b/gcc/ipa-modref.cc
@@ -1753,8 +1753,7 @@ modref_access_analysis::analyze_store (gimple *stmt, tree, tree op, void *data)
t->record_access_lto (t->m_summary_lto->stores, &r, a);
if (t->m_always_executed
&& a.useful_for_kill_p ()
- && (!cfun->can_throw_non_call_exceptions
- || !stmt_could_throw_p (cfun, stmt)))
+ && !stmt_could_throw_p (cfun, stmt))
{
if (dump_file)
fprintf (dump_file, " - Recording kill\n");
diff --git a/gcc/testsuite/g++.dg/torture/pr111245.C b/gcc/testsuite/g++.dg/torture/pr111245.C
new file mode 100644
index 0000000..785f4a5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr111245.C
@@ -0,0 +1,23 @@
+/* { dg-do run } */
+
+struct Int {
+ int value;
+};
+
+__attribute__((noipa)) Int always_throws() { throw 123; }
+
+void foo(Int &x) {
+ try {
+ x = always_throws();
+ } catch (...) {
+ }
+}
+
+int main()
+{
+ Int x;
+ x.value = 5;
+ foo(x);
+ if (x.value != 5)
+ __builtin_abort ();
+}