]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Backport PRs 91606, 91772, 91790, 91812, 91968
authorRichard Biener <rguenther@suse.de>
Wed, 16 Oct 2019 09:25:34 +0000 (09:25 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 16 Oct 2019 09:25:34 +0000 (09:25 +0000)
2019-10-16  Richard Biener  <rguenther@suse.de>

Backport from mainline
2019-10-04  Richard Biener  <rguenther@suse.de>

PR lto/91968
* tree.c (find_decls_types_r): Do not remove LABEL_DECLs from
BLOCK_VARS.

2019-10-02  Richard Biener  <rguenther@suse.de>

PR c++/91606
* decl.c (build_ptrmemfunc_type): Mark pointer-to-member
fat pointer structure members as DECL_NONADDRESSABLE_P.

* g++.dg/torture/pr91606.C: New testcase.

2019-09-19  Richard Biener  <rguenther@suse.de>

PR tree-optimization/91812
* tree-ssa-phiprop.c (propagate_with_phi): Do not replace
volatile loads.

* gcc.dg/torture/pr91812.c: New testcase.

2019-09-17  Richard Biener  <rguenther@suse.de>

PR debug/91772
* dwarf2out.c (dwarf2out_late_global_decl): If early dwarf
was missing generate locations only once.

2019-09-17  Richard Biener  <rguenther@suse.de>

PR tree-optimization/91790
* tree-vect-stmts.c (vectorizable_load): For BB vectorization
use the correct DR for setting up realignment.

From-SVN: r277055

gcc/ChangeLog
gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/dwarf2out.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr91606.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr91812.c [new file with mode: 0644]
gcc/tree-ssa-phiprop.c
gcc/tree-vect-stmts.c
gcc/tree.c

index e89beb41972eb41d32079566c606406e5c3c8b71..484acf68648621e3351defcb8af7334c8a5f398c 100644 (file)
@@ -1,3 +1,30 @@
+2019-10-16  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2019-10-04  Richard Biener  <rguenther@suse.de>
+
+       PR lto/91968
+       * tree.c (find_decls_types_r): Do not remove LABEL_DECLs from
+       BLOCK_VARS.
+
+       2019-09-19  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/91812
+       * tree-ssa-phiprop.c (propagate_with_phi): Do not replace
+       volatile loads.
+
+       2019-09-17  Richard Biener  <rguenther@suse.de>
+
+       PR debug/91772
+       * dwarf2out.c (dwarf2out_late_global_decl): If early dwarf
+       was missing generate locations only once.
+
+       2019-09-17  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/91790
+       * tree-vect-stmts.c (vectorizable_load): For BB vectorization
+       use the correct DR for setting up realignment.
+
 2019-10-14  Will Schmidt  <will_schmidt@vnet.ibm.com>
 
        Backport from trunk
index 9a9dc437231b30c949e37c41f01fd89f5fa316d6..095d27f68d3ceda5c14ebfd24be44033c736d1a9 100644 (file)
@@ -1,3 +1,12 @@
+2019-10-16  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2019-10-02  Richard Biener  <rguenther@suse.de>
+
+       PR c++/91606
+       * decl.c (build_ptrmemfunc_type): Mark pointer-to-member
+       fat pointer structure members as DECL_NONADDRESSABLE_P.
+
 2019-10-08  Marek Polacek  <polacek@redhat.com>
 
        Backported from mainline
index e860f26e55d88c264d90988c4f0b309461b95f32..2b207e4759b6485b66f8c79b275e1eadd047474b 100644 (file)
@@ -9554,10 +9554,12 @@ build_ptrmemfunc_type (tree type)
   TYPE_PTRMEMFUNC_FLAG (t) = 1;
 
   field = build_decl (input_location, FIELD_DECL, pfn_identifier, type);
+  DECL_NONADDRESSABLE_P (field) = 1;
   fields = field;
 
   field = build_decl (input_location, FIELD_DECL, delta_identifier, 
                      delta_type_node);
+  DECL_NONADDRESSABLE_P (field) = 1;
   DECL_CHAIN (field) = fields;
   fields = field;
 
index 1cec00f2b857b248ad13a3268d15560eb1c35b23..60a986e1c3019c4284b6c6aeac1ebefc982f81a9 100644 (file)
@@ -26647,16 +26647,12 @@ dwarf2out_late_global_decl (tree decl)
     {
       dw_die_ref die = lookup_decl_die (decl);
 
-      /* We may have to generate early debug late for LTO in case debug
+      /* We may have to generate full debug late for LTO in case debug
          was not enabled at compile-time or the target doesn't support
         the LTO early debug scheme.  */
       if (! die && in_lto_p)
-       {
-         dwarf2out_decl (decl);
-         die = lookup_decl_die (decl);
-       }
-
-      if (die)
+       dwarf2out_decl (decl);
+      else if (die)
        {
          /* We get called via the symtab code invoking late_global_decl
             for symbols that are optimized out.
index d05bd15f94189e2633465cd6041f4a2aa7769d19..ab2f9044bfe1edd71c11ef8476dd738c5c8b0dfc 100644 (file)
@@ -1,3 +1,16 @@
+2019-10-16  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2019-10-02  Richard Biener  <rguenther@suse.de>
+
+       PR c++/91606
+       * g++.dg/torture/pr91606.C: New testcase.
+
+       2019-09-19  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/91812
+       * gcc.dg/torture/pr91812.c: New testcase.
+
 2019-10-14  Will Schmidt  <will_schmidt@vnet.ibm.com>
 
        Backport from trunk.
diff --git a/gcc/testsuite/g++.dg/torture/pr91606.C b/gcc/testsuite/g++.dg/torture/pr91606.C
new file mode 100644 (file)
index 0000000..37a05a5
--- /dev/null
@@ -0,0 +1,109 @@
+/* { dg-do run } */
+/* { dg-additional-options "-fstrict-aliasing" } */
+
+#include <cstdlib>
+#include <array>
+#include <type_traits>
+
+template <typename T1, typename T2>
+struct variant
+{
+  constexpr variant(T1 arg)
+      : f1(arg),
+      index(0)
+  {}
+
+  constexpr variant(T2 arg)
+      : f2(arg),
+      index(1)
+  {}
+
+  union
+    {
+      T1 f1;
+      T2 f2;
+    };
+  std::size_t index = 0;
+};
+
+template <typename T1, typename T2>
+constexpr const T1* get_if(const variant<T1, T2>* v)
+{
+  if (v->index != 0)
+    {
+      return nullptr;
+    }
+  return &v->f1;
+}
+
+template <typename T2, typename T1>
+constexpr const T2* get_if(const variant<T1, T2>* v)
+{
+  if (v->index != 1)
+    {
+      return nullptr;
+    }
+  return &v->f2;
+}
+
+template <typename T, size_t N>
+struct my_array
+{
+  constexpr const T* begin() const
+    {
+      return data;
+    }
+
+  constexpr const T* end() const
+    {
+      return data + N;
+    }
+
+  T data[N];
+};
+
+template <typename ...Ts>
+constexpr auto get_array_of_variants(Ts ...ptrs)
+{
+  return std::array<variant<std::decay_t<Ts>...>, sizeof...(Ts)>{ ptrs... };
+}
+
+template <typename T>
+constexpr auto get_member_functions();
+
+template <typename Member, typename Class>
+constexpr int getFuncId(Member (Class::*memFuncPtr))
+{
+  int idx = 0u;
+  for (auto &anyFunc : get_member_functions<Class>())
+    {
+      if (auto *specificFunc = get_if<Member (Class::*)>(&anyFunc))
+       {
+         if (*specificFunc == memFuncPtr)
+           {
+             return idx;
+           }
+       }
+      ++idx;
+    }
+  std::abort();
+}
+
+struct MyStruct
+{
+  void fun1(int /*a*/) {}
+
+  int fun2(char /*b*/, short /*c*/, bool /*d*/) { return 0; }
+
+};
+
+template <>
+constexpr auto get_member_functions<MyStruct>()
+{
+  return get_array_of_variants(&MyStruct::fun1, &MyStruct::fun2);
+}
+
+int main()
+{
+  return getFuncId(&MyStruct::fun1);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr91812.c b/gcc/testsuite/gcc.dg/torture/pr91812.c
new file mode 100644 (file)
index 0000000..ebc67a0
--- /dev/null
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } { "" } } */
+/* { dg-options "-fdump-tree-optimized-blocks" } */
+
+unsigned register1;
+unsigned register2;
+
+void busy_wait_for_register (int x)
+{
+  volatile unsigned* ptr;
+  switch(x) {
+    case 0x1111:
+    ptr = &register1;
+    break;
+
+    case 0x2222:
+    ptr = &register2;
+    break;
+
+    default:
+    return;
+  }
+  while (*ptr) {}
+}
+
+/* { dg-final { scan-tree-dump "loop depth 1" "optimized" } } */
index d710582a915e417e6d6ee698076942dae3babca6..e90ae6a89cb5196267f3836f85a46311aa2c6e06 100644 (file)
@@ -338,8 +338,15 @@ propagate_with_phi (basic_block bb, gphi *phi, struct phiprop_d *phivn,
            && (!type
                || types_compatible_p
                     (TREE_TYPE (gimple_assign_lhs (use_stmt)), type))
-           /* We cannot replace a load that may throw or is volatile.  */
-           && !stmt_can_throw_internal (cfun, use_stmt)))
+           /* We cannot replace a load that may throw or is volatile.
+              For volatiles the transform can change the number of
+              executions if the load is inside a loop but the address
+              computations outside (PR91812).  We could relax this
+              if we guard against that appropriately.  For loads that can
+              throw we could relax things if the moved loads all are
+              known to not throw.  */
+           && !stmt_can_throw_internal (cfun, use_stmt)
+           && !gimple_has_volatile_ops (use_stmt)))
        continue;
 
       /* Check if we can move the loads.  The def stmt of the virtual use
index 17769c88b6a0c7fb1f60ea3a2f2579758c64d7ef..ad998aa5770e62bf01c8fadcc666fcea712a1bd9 100644 (file)
@@ -8276,7 +8276,9 @@ vectorizable_load (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
        || alignment_support_scheme == dr_explicit_realign)
       && !compute_in_loop)
     {
-      msq = vect_setup_realignment (first_stmt_info, gsi, &realignment_token,
+      msq = vect_setup_realignment (first_stmt_info_for_drptr
+                                   ? first_stmt_info_for_drptr
+                                   : first_stmt_info, gsi, &realignment_token,
                                    alignment_support_scheme, NULL_TREE,
                                    &at_loop);
       if (alignment_support_scheme == dr_explicit_realign_optimized)
index 337b95a85e2ad77e64f29f75f280073b74649183..36ccdae3793504bcc0014a1f96dfaa03e938efa5 100644 (file)
@@ -5936,8 +5936,9 @@ find_decls_types_r (tree *tp, int *ws, void *data)
     {
       for (tree *tem = &BLOCK_VARS (t); *tem; )
        {
-         if (TREE_CODE (*tem) != VAR_DECL
-             || !auto_var_in_fn_p (*tem, DECL_CONTEXT (*tem)))
+         if (TREE_CODE (*tem) != LABEL_DECL
+             && (TREE_CODE (*tem) != VAR_DECL
+                 || !auto_var_in_fn_p (*tem, DECL_CONTEXT (*tem))))
            {
              gcc_assert (TREE_CODE (*tem) != RESULT_DECL
                          && TREE_CODE (*tem) != PARM_DECL);