]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ipa-sra: Check also ECF_LOOPING_CONST_OR_PURE when evaluating calls
authorMartin Jambor <mjambor@suse.cz>
Wed, 1 Dec 2021 13:25:16 +0000 (14:25 +0100)
committerMartin Jambor <mjambor@suse.cz>
Wed, 1 Dec 2021 13:27:04 +0000 (14:27 +0100)
in PR 103267 Honza found out that IPA-SRA does not look at
ECF_LOOPING_CONST_OR_PURE when evaluating if a call can have side
effects.  Fixed with this patch.  The testcase infinitely loops in a
const function, so it would not make a good addition to the testsuite.

gcc/ChangeLog:

2021-11-29  Martin Jambor  <mjambor@suse.cz>

PR ipa/103267
* ipa-sra.c (scan_function): Also check ECF_LOOPING_CONST_OR_PURE flag.

(cherry picked from commit e5440bc08e07fd491dcccd47e1b86a5985ee117c)

gcc/ipa-sra.c

index 8ad57493ea6a56dfcaccb26be47c8ae66f772af3..2f7fa9f9fc804581c3dcf1b0d5e3b823c5cd25b8 100644 (file)
@@ -1912,7 +1912,8 @@ scan_function (cgraph_node *node, struct function *fun)
                if (lhs)
                  scan_expr_access (lhs, stmt, ISRA_CTX_STORE, bb);
                int flags = gimple_call_flags (stmt);
-               if ((flags & (ECF_CONST | ECF_PURE)) == 0)
+               if (((flags & (ECF_CONST | ECF_PURE)) == 0)
+                   || (flags & ECF_LOOPING_CONST_OR_PURE))
                  bitmap_set_bit (final_bbs, bb->index);
              }
              break;