aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2019-10-16 09:25:34 +0000
committerRichard Biener <rguenther@suse.de>2019-10-16 09:25:34 +0000
commit99dd49d8e519807c1a4b7643ec6cf2112c99eda9 (patch)
tree26a9da57becf957c62faa3e5751288aa4ee4d1f6
parentead337d088b1be0d5b08d6af8b884c3e57dd9a47 (diff)
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. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/gcc-9-branch@277055 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog27
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/decl.c2
-rw-r--r--gcc/dwarf2out.c10
-rw-r--r--gcc/testsuite/ChangeLog13
-rw-r--r--gcc/testsuite/g++.dg/torture/pr91606.C109
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr91812.c26
-rw-r--r--gcc/tree-ssa-phiprop.c11
-rw-r--r--gcc/tree-vect-stmts.c4
-rw-r--r--gcc/tree.c5
10 files changed, 204 insertions, 12 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e89beb41972..484acf68648 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 9a9dc437231..095d27f68d3 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index e860f26e55d..2b207e4759b 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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;
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 1cec00f2b85..60a986e1c30 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -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.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index d05bd15f941..ab2f9044bfe 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 00000000000..37a05a5e3a5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr91606.C
@@ -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
index 00000000000..ebc67a01e33
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr91812.c
@@ -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" } } */
diff --git a/gcc/tree-ssa-phiprop.c b/gcc/tree-ssa-phiprop.c
index d710582a915..e90ae6a89cb 100644
--- a/gcc/tree-ssa-phiprop.c
+++ b/gcc/tree-ssa-phiprop.c
@@ -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
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 17769c88b6a..ad998aa5770 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -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)
diff --git a/gcc/tree.c b/gcc/tree.c
index 337b95a85e2..36ccdae3793 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -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);