]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Reload global options when strict aliasing is dropped (PR ipa/79043).
authorMartin Liska <mliska@suse.cz>
Fri, 20 Jan 2017 12:09:22 +0000 (13:09 +0100)
committerMartin Liska <marxin@gcc.gnu.org>
Fri, 20 Jan 2017 12:09:22 +0000 (12:09 +0000)
2017-01-20  Martin Liska  <mliska@suse.cz>

Backport from mainline
2017-01-13  Martin Liska  <mliska@suse.cz>

PR ipa/79043
* function.c (set_cfun): Add new argument force.
* function.h (set_cfun): Likewise.
* ipa-inline-transform.c (inline_call): Use the function when
strict alising from is dropped for function we inline to.
2017-01-20  Martin Liska  <mliska@suse.cz>

Backport from mainline
2017-01-13  Martin Liska  <mliska@suse.cz>

PR ipa/79043
* gcc.c-torture/execute/pr79043.c: New test.

From-SVN: r244709

gcc/ChangeLog
gcc/function.c
gcc/function.h
gcc/ipa-inline-transform.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr79043.c [new file with mode: 0644]

index 065ba81ef14c56e2429ec8f69ec5576a27e45e84..b652f23dbadcb8622d6855414ec41121384b9e63 100644 (file)
@@ -1,3 +1,14 @@
+2017-01-20  Martin Liska  <mliska@suse.cz>
+
+       Backport from mainline
+       2017-01-13  Martin Liska  <mliska@suse.cz>
+
+       PR ipa/79043
+       * function.c (set_cfun): Add new argument force.
+       * function.h (set_cfun): Likewise.
+       * ipa-inline-transform.c (inline_call): Use the function when
+       strict alising from is dropped for function we inline to.
+
 2017-01-20  Martin Liska  <mliska@suse.cz>
 
        Backport from mainline
index 5059cdf634b23d59f484268a03ae9eca3f77e563..8b640584b0b77318e589e84a9f6b3502f5d7e13b 100644 (file)
@@ -4688,9 +4688,9 @@ invoke_set_current_function_hook (tree fndecl)
 /* cfun should never be set directly; use this function.  */
 
 void
-set_cfun (struct function *new_cfun)
+set_cfun (struct function *new_cfun, bool force)
 {
-  if (cfun != new_cfun)
+  if (cfun != new_cfun || force)
     {
       cfun = new_cfun;
       invoke_set_current_function_hook (new_cfun ? new_cfun->decl : NULL_TREE);
index b89c5aeefb677f1d516b5f07a0e19e4a723c7c25..bfa6f80caeec0f84daa0dabdc655a9475fd7c205 100644 (file)
@@ -891,7 +891,7 @@ extern tree block_chainon (tree, tree);
 extern void number_blocks (tree);
 
 /* cfun shouldn't be set directly; use one of these functions instead.  */
-extern void set_cfun (struct function *new_cfun);
+extern void set_cfun (struct function *new_cfun, bool force = false);
 extern void push_cfun (struct function *new_cfun);
 extern void pop_cfun (void);
 
index c56ada49c98d0e34b2e48bdbdf1461fa633cab6e..855d2231c650c402fd5d8e819cf1fa7ca5038b25 100644 (file)
@@ -341,6 +341,8 @@ inline_call (struct cgraph_edge *e, bool update_original,
   if (DECL_FUNCTION_PERSONALITY (callee->decl))
     DECL_FUNCTION_PERSONALITY (to->decl)
       = DECL_FUNCTION_PERSONALITY (callee->decl);
+
+  bool reload_optimization_node = false;
   if (!opt_for_fn (callee->decl, flag_strict_aliasing)
       && opt_for_fn (to->decl, flag_strict_aliasing))
     {
@@ -354,8 +356,13 @@ inline_call (struct cgraph_edge *e, bool update_original,
       build_optimization_node (&opts);
       DECL_FUNCTION_SPECIFIC_OPTIMIZATION (to->decl)
         = build_optimization_node (&opts);
+      reload_optimization_node = true;
     }
 
+  /* Reload global optimization flags.  */
+  if (reload_optimization_node && DECL_STRUCT_FUNCTION (to->decl) == cfun)
+    set_cfun (cfun, true);
+
   /* If aliases are involved, redirect edge to the actual destination and
      possibly remove the aliases.  */
   if (e->callee != callee)
index 975a1e5742245ce5a9357bfc382f1a3daa7f7372..26dc594ecd2b0794e9b918e27bb257b1f3dd9326 100644 (file)
@@ -1,3 +1,11 @@
+2017-01-20  Martin Liska  <mliska@suse.cz>
+
+       Backport from mainline
+       2017-01-13  Martin Liska  <mliska@suse.cz>
+
+       PR ipa/79043
+       * gcc.c-torture/execute/pr79043.c: New test.
+
 2017-01-20  Martin Liska  <mliska@suse.cz>
 
        Backport from mainline
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr79043.c b/gcc/testsuite/gcc.c-torture/execute/pr79043.c
new file mode 100644 (file)
index 0000000..b7fcc82
--- /dev/null
@@ -0,0 +1,21 @@
+/* PR ipa/78791 */
+
+int val;
+
+int *ptr = &val;
+float *ptr2 = &val;
+
+static
+__attribute__((always_inline, optimize ("-fno-strict-aliasing")))
+typepun ()
+{
+  *ptr2=0;
+}
+
+main()
+{
+  *ptr=1;
+  typepun ();
+  if (*ptr)
+    __builtin_abort ();
+}