From 718f30af33ffafbcafb1fbe90967489d4ffabc26 Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Mon, 23 Apr 2018 20:19:39 +0000 Subject: [PATCH] PR middle-end/85496 * expr.c (store_field): In the bitfield case, if the value comes from a function call and is returned in registers by means of a PARALLEL, do not change the mode of the temporary unless BLKmode and VOIDmode. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@259574 138bc75d-0d04-0410-961f-82ee72b054a4 This Fix is from gcc-mainline (branch for gcc-6) Bug report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85496 Fix report: https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=259577 Related issue of tensorflow: https://github.com/tensorflow/tensorflow/issues/25323 Related build errors in Tizen (tensorflow / aarch64): [ 3281s] exec env - \ [ 3281s] LD_LIBRARY_PATH=/usr/lib64 \ [ 3281s] PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/home/abuild/rpmbuild/BUILD/tensorflow-v1.13.1 \ [ 3281s] PWD=/proc/self/cwd \ [ 3281s] PYTHON_BIN_PATH=/bin/python \ [ 3281s] PYTHON_LIB_PATH=/usr/lib/python2.7/site-packages \ [ 3281s] TF_DOWNLOAD_CLANG=0 \ [ 3281s] TF_NEED_CUDA=0 \ [ 3281s] TF_NEED_OPENCL_SYCL=0 \ [ 3281s] TF_NEED_ROCM=0 \ [ 3281s] /bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -B/bin -B/usr/bin -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections -fdata-sections '-std=c++0x' -MD -MF bazel-out/aarch64-opt/bin/tensorflow/compiler/xla/service/cpu/_objs/runtime_conv2d/runtime_conv2d.pic.d '-frandom-seed=bazel-out/aarch64-opt/bin/tensorflow/compiler/xla/service/cpu/_objs/runtime_conv2d/runtime_conv2d.pic.o' -fPIC -DEIGEN_MPL2_ONLY '-DEIGEN_MAX_ALIGN_BYTES=64' '-DEIGEN_HAS_TYPE_TRAITS=0' -iquote . -iquote bazel-out/aarch64-opt/genfiles -iquote bazel-out/aarch64-opt/bin -iquote external/nsync -iquote bazel-out/aarch64-opt/genfiles/external/nsync -iquote bazel-out/aarch64-opt/bin/external/nsync -iquote external/bazel_tools -iquote bazel-out/aarch64-opt/genfiles/external/bazel_tools -iquote bazel-out/aarch64-opt/bin/external/bazel_tools -iquote external/eigen_archive -iquote bazel-out/aarch64-opt/genfiles/external/eigen_archive -iquote bazel-out/aarch64-opt/bin/external/eigen_archive -iquote external/local_config_sycl -iquote bazel-out/aarch64-opt/genfiles/external/local_config_sycl -iquote bazel-out/aarch64-opt/bin/external/local_config_sycl -isystem external/nsync/public -isystem bazel-out/aarch64-opt/genfiles/external/nsync/public -isystem bazel-out/aarch64-opt/bin/external/nsync/public -isystem external/eigen_archive -isystem bazel-out/aarch64-opt/genfiles/external/eigen_archive -isystem bazel-out/aarch64-opt/bin/external/eigen_archive '-march=armv8-a+fp+simd+crc+crypto' -Wno-sign-compare '-D_GLIBCXX_USE_CXX11_ABI=0' '-std=c++11' -DEIGEN_AVOID_STL_ARRAY -fno-canonical-system-headers -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c tensorflow/compiler/xla/service/cpu/runtime_conv2d.cc -o bazel-out/aarch64-opt/bin/tensorflow/compiler/xla/service/cpu/_objs/runtime_conv2d/runtime_conv2d.pic.o) [ 3281s] In file included from external/eigen_archive/Eigen/Core:296:0, [ 3281s] from ./third_party/eigen3/Eigen/Core:1, [ 3281s] from ./tensorflow/compiler/xla/service/cpu/runtime_conv2d.h:19, [ 3281s] from tensorflow/compiler/xla/service/cpu/runtime_conv2d.cc:16: [ 3281s] external/eigen_archive/Eigen/src/Core/products/GeneralBlockPanelKernel.h: In member function 'void Eigen::internal::gebp_kernel::operator()(const DataMapper&, const LhsScalar*, const RhsScalar*, Index, Index, Index, Eigen::internal::gebp_kernel::ResScalar, Index, Index, Index, Index) [with LhsScalar = Eigen::half; RhsScalar = Eigen::half; Index = long int; DataMapper = Eigen::internal::blas_data_mapper; int mr = 2; int nr = 4; bool ConjugateLhs = false; bool ConjugateRhs = false]': [ 3281s] external/eigen_archive/Eigen/src/Core/products/GeneralBlockPanelKernel.h:1879:3: internal compiler error: in emit_move_insn, at expr.c:3547 [ 3281s] } [ 3281s] ^ [ 3281s] Please submit a full bug report, [ 3281s] with preprocessed source if appropriate. [ 3281s] See for instructions. [ 3284s] Target //tensorflow/tools/lib_package:libtensorflow failed to build [ 3284s] INFO: Elapsed time: 3254.811s, Critical Path: 366.23s, Remote (0.00% of the time): [queue: 0.00%, setup: 0.00%, process: 0.00%] [ 3284s] INFO: 1643 processes: 1643 local. [ 3284s] FAILED: Build did NOT complete successfully [ 3284s] FAILED: Build did NOT complete successfully [ 3285s] error: Bad exit status from /var/tmp/rpm-tmp.YdwJ8i (%build) Because this fix requires yet another older fix, part of the older fix is merged from the following mainline commit. Author: rsandifo 2017-08-30 20:10:44 Committer: rsandifo 2017-08-30 20:10:44 Parent: 2cf1bb2548bf9ce652251e4f7870e67b080acf56 ([18/77] Make int_mode_for_mode return an opt_scalar_int_mode) Child: 8b449599ee018840a92725b17e06374b0f8787c0 ([20/77] Replace MODE_INT checks with is_int_mode) [19/77] Add a smallest_int_mode_for_size helper function Change-Id: I5e22ed657099d7a1ac19b451c436f8e4831c6c76 Signed-off-by: MyungJoo Ham --- gcc/ChangeLog | 7 +++++++ gcc/expr.c | 5 +++-- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/g++.dg/torture/pr85496.C | 18 ++++++++++++++++++ 4 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/torture/pr85496.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ecad014..b93fe69 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2018-04-23 Eric Botcazou + + PR middle-end/85496 + * expr.c (store_field): In the bitfield case, if the value comes from + a function call and is returned in registers by means of a PARALLEL, + do not change the mode of the temporary unless BLKmode and VOIDmode. + 2019-02-15 Eric Botcazou * asan.c (asan_emit_stack_protection): Use full-sized mask to align diff --git a/gcc/expr.c b/gcc/expr.c index 6342c0a..b3645fb 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -6693,8 +6693,9 @@ store_field (rtx target, HOST_WIDE_INT bitsize, HOST_WIDE_INT bitpos, if (GET_CODE (temp) == PARALLEL) { HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (exp)); - machine_mode temp_mode - = smallest_mode_for_size (size * BITS_PER_UNIT, MODE_INT); + machine_mode temp_mode = GET_MODE (temp); + if (temp_mode == BLKmode || temp_mode == VOIDmode) + temp_mode = smallest_mode_for_size (size * BITS_PER_UNIT, MODE_INT); rtx temp_target = gen_reg_rtx (temp_mode); emit_group_store (temp_target, temp, TREE_TYPE (exp), size); temp = temp_target; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7dc8ba3..52de66b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2018-04-23 Eric Botcazou + + * g++.dg/torture/pr85496.C: New test. + 2018-12-05 Jakub Jelinek PR sanitizer/88333 diff --git a/gcc/testsuite/g++.dg/torture/pr85496.C b/gcc/testsuite/g++.dg/torture/pr85496.C new file mode 100644 index 0000000..3f504a3 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr85496.C @@ -0,0 +1,18 @@ +// PR middle-end/85496 +// Reported by Marek Polacek + +template class complex; +template complex<_Tp> operator*(complex<_Tp>, complex<_Tp>); +template <> struct complex { _Complex float _M_value; }; +class A { + complex _f0, _f1; + +public: + complex &m_fn1() { return _f1; } +}; +complex a; +void cos() { + A b; + complex c; + b.m_fn1() = c * a; +} -- 2.7.4