re PR ipa/87024 (ICE in fold_stmt_1)
authorRichard Biener <rguenther@suse.de>
Thu, 23 Aug 2018 09:29:45 +0000 (09:29 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 23 Aug 2018 09:29:45 +0000 (09:29 +0000)
2018-08-23  Richard Biener  <rguenther@suse.de>

PR middle-end/87024
* tree-inline.c (copy_bb): Drop unused __builtin_va_arg_pack_len
calls.

* gcc.dg/pr87024.c: New testcase.

From-SVN: r263805

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr87024.c [new file with mode: 0644]
gcc/tree-inline.c

index 64e6d8e7b974397ca3ed9f88e41c1a4f6248eef7..89dfeb9f81fbfd0461d55d260c80be7af8d0ccc5 100644 (file)
@@ -1,3 +1,9 @@
+2018-08-23  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/87024
+       * tree-inline.c (copy_bb): Drop unused __builtin_va_arg_pack_len
+       calls.
+
 2018-08-23  Richard Sandiford  <richard.sandiford@arm.com>
 
        * config/aarch64/aarch64.c (aarch64_evpc_sve_tbl): Fix handling
index 95fd2e58fe740f3a07fb4ae29aa743ec160ec5cb..bf2295bcdea89318304369d73083ca4c0a2985ac 100644 (file)
@@ -1,3 +1,8 @@
+2018-08-23  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/87024
+       * gcc.dg/pr87024.c: New testcase.
+
 2018-08-23  Richard Sandiford  <richard.sandiford@arm.com>
 
        * gcc.dg/vect/no-vfa-vect-depend-2.c: Remove XFAIL.
diff --git a/gcc/testsuite/gcc.dg/pr87024.c b/gcc/testsuite/gcc.dg/pr87024.c
new file mode 100644 (file)
index 0000000..a8a58aa
--- /dev/null
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fno-tree-dce" } */
+
+static inline void __attribute__((always_inline))
+mp ()
+{
+  (void) __builtin_va_arg_pack_len ();
+}
+
+void
+ui (void)
+{
+  mp ();
+}
index 2b6bb5c0e3136e28d036827994d685f93fba3849..ef615cc347e837d9cb3c9980322f40ae65680fdf 100644 (file)
@@ -1951,7 +1951,13 @@ copy_bb (copy_body_data *id, basic_block bb,
              for (p = DECL_ARGUMENTS (id->src_fn); p; p = DECL_CHAIN (p))
                nargs--;
 
-             if (!gimple_call_va_arg_pack_p (id->call_stmt))
+             if (!gimple_call_lhs (stmt))
+               {
+                 /* Drop unused calls.  */
+                 gsi_remove (&copy_gsi, false);
+                 continue;
+               }
+             else if (!gimple_call_va_arg_pack_p (id->call_stmt))
                {
                  count = build_int_cst (integer_type_node, nargs);
                  new_stmt = gimple_build_assign (gimple_call_lhs (stmt), count);