diff --git a/fix-avoid-bogus-uninit-warning-with-store-motion.patch b/fix-avoid-bogus-uninit-warning-with-store-motion.patch new file mode 100644 index 0000000000000000000000000000000000000000..0a664b417823fe16d581fe9c85fc696885fcce16 --- /dev/null +++ b/fix-avoid-bogus-uninit-warning-with-store-motion.patch @@ -0,0 +1,85 @@ +This backport contains 1 patch from gcc main stream tree. +The commit id of these patchs list as following in the order of time. + +0001-tree-optimization-94963-avoid-bogus-uninit-warning-with-store-motion.patch +371905d12259c180efb9b1f1b5716e969feb60f9 + +diff --git a/gcc/testsuite/gcc.dg/pr94963.c b/gcc/testsuite/gcc.dg/pr94963.c +new file mode 100644 +index 00000000000..aca9e161301 +--- /dev/null ++++ b/gcc/testsuite/gcc.dg/pr94963.c +@@ -0,0 +1,35 @@ ++/* { dg-do compile } */ ++/* { dg-options "-O2 -Wall" } */ ++ ++typedef struct ++{ ++ int p1; ++ int p2; ++ int p3; ++} P; ++struct S ++{ ++ int field; ++}; ++extern int v2; ++extern void foo (struct S *map); ++static struct S var; ++const P *pv; ++int ps; ++void ++f (void) ++{ ++ if (pv != 0) ++ for (const P *ph = pv; ph < &pv[ps]; ++ph) ++ switch (ph->p1) ++ { ++ case 1: ++ v2 = ph->p2; ++ break; ++ case 2: ++ var.field = ph->p3; ++ break; ++ } ++ if (var.field != 0) /* { dg-bogus "uninitialized" } */ ++ foo (&var); ++} +diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c +index 554dd4be5bb..3056b4bfed2 100644 +--- a/gcc/tree-ssa-loop-im.c ++++ b/gcc/tree-ssa-loop-im.c +@@ -1994,8 +1994,6 @@ execute_sm_if_changed (edge ex, tree mem, tree tmp_var, tree flag, + gsi = gsi_start_bb (then_bb); + /* Insert actual store. */ + stmt = gimple_build_assign (unshare_expr (mem), tmp_var); +- /* Make sure to not warn about maybe-uninit uses of tmp_var here. */ +- gimple_set_no_warning (stmt, true); + gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING); + + edge e1 = single_succ_edge (new_bb); +@@ -2149,13 +2147,19 @@ execute_sm (class loop *loop, vec exits, im_mem_ref *ref) + store then. */ + if ((!always_stored && !multi_threaded_model_p) + || (ref->loaded && bitmap_bit_p (ref->loaded, loop->num))) ++ load = gimple_build_assign (tmp_var, unshare_expr (ref->mem.ref)); ++ else + { +- load = gimple_build_assign (tmp_var, unshare_expr (ref->mem.ref)); +- lim_data = init_lim_data (load); +- lim_data->max_loop = loop; +- lim_data->tgt_loop = loop; +- gsi_insert_before (&gsi, load, GSI_SAME_STMT); ++ /* If not emitting a load mark the uninitialized state on the ++ loop entry as not to be warned for. */ ++ tree uninit = create_tmp_reg (TREE_TYPE (tmp_var)); ++ TREE_NO_WARNING (uninit) = 1; ++ load = gimple_build_assign (tmp_var, uninit); + } ++ lim_data = init_lim_data (load); ++ lim_data->max_loop = loop; ++ lim_data->tgt_loop = loop; ++ gsi_insert_before (&gsi, load, GSI_SAME_STMT); + + if (multi_threaded_model_p) + { diff --git a/gcc.spec b/gcc.spec index a0e5fc29da6a5fb991169bc9b62f2d0f9f723af5..fb819094363a53a3915234adc973f5191bdbc44f 100644 --- a/gcc.spec +++ b/gcc.spec @@ -1,4 +1,4 @@ -%global DATE 20200828 +%global DATE 20200905 %global gcc_version 9.3.1 %global gcc_major 9.3.1 @@ -59,7 +59,7 @@ Summary: Various compilers (C, C++, Objective-C, ...) Name: gcc Version: %{gcc_version} -Release: %{DATE}.3 +Release: %{DATE}.4 License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD Source0: gcc-9.3.0.tar.xz %global isl_version 0.16.1 @@ -174,6 +174,7 @@ Patch59: fix-wrong-vectorizer-code.patch Patch60: fix-load-eliding-in-SM.patch Patch61: fix-SSA-update-for-vectorizer-epilogue.patch Patch62: fix-ICE-when-vectorizing-nested-cycles.patch +Patch63: fix-avoid-bogus-uninit-warning-with-store-motion.patch %global gcc_target_platform %{_arch}-linux-gnu @@ -679,6 +680,7 @@ not stable, so plugins must be rebuilt any time GCC is updated. %patch60 -p1 %patch61 -p1 %patch62 -p1 +%patch63 -p1 %build @@ -2607,6 +2609,9 @@ end %doc rpm.doc/changelogs/libcc1/ChangeLog* %changelog +* Sat Sep 05 2020 eastb233 - 9.3.1-20200905.4 +- fix-avoid-bogus-uninit-warning-with-store-motion.patch: New file + * Mon Aug 28 2020 eastb233 - 9.3.1-20200828.4 - Add add-checks-to-avoid-spoiling-if-conversion.patch - Add add-option-fallow-store-data-races.patch