]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Pass unpromoted argument to promote_function_mode
authorH.J. Lu <hongjiu.lu@intel.com>
Fri, 5 Dec 2014 12:02:33 +0000 (12:02 +0000)
committerH.J. Lu <hjl@gcc.gnu.org>
Fri, 5 Dec 2014 12:02:33 +0000 (04:02 -0800)
This patch updates setup_incoming_promotions in combine.c to match what
is actually passed in assign_parm_setup_reg in function.c.

gcc/

Backport from mainline
PR rtl-optimization/64037
* combine.c (setup_incoming_promotions): Pass the argument
before any promotions happen to promote_function_mode.

gcc/testsuite/

Backport from mainline
PR rtl-optimization/64037
* g++.dg/pr64037.C: New test.

From-SVN: r218420

gcc/ChangeLog
gcc/combine.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/pr64037.C [new file with mode: 0644]

index ba46f179f38bc7c0dde69cfeb53656c1d552ace3..2faff6a64841dcd56d451efa437c0c68f2b38869 100644 (file)
@@ -1,3 +1,12 @@
+2014-12-05  H.J. Lu  <hongjiu.lu@intel.com>
+
+       Backport from mainline
+       2014-11-28  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR rtl-optimization/64037
+       * combine.c (setup_incoming_promotions): Pass the argument
+       before any promotions happen to promote_function_mode.
+
 2014-12-04  Shanyao Chen  <chenshanyao@huawei.com>
 
        Backport from mainline
index 0cdd37b9465fc8067d52864421f93f6a16f33bce..a7b1829a105cf2c032d94bfba43bfffa51eedd18 100644 (file)
@@ -1527,8 +1527,8 @@ setup_incoming_promotions (rtx first)
       uns3 = TYPE_UNSIGNED (DECL_ARG_TYPE (arg));
 
       /* The mode and signedness of the argument as it is actually passed,
-         after any TARGET_PROMOTE_FUNCTION_ARGS-driven ABI promotions.  */
-      mode3 = promote_function_mode (DECL_ARG_TYPE (arg), mode2, &uns3,
+         see assign_parm_setup_reg in function.c.  */
+      mode3 = promote_function_mode (TREE_TYPE (arg), mode1, &uns1,
                                     TREE_TYPE (cfun->decl), 0);
 
       /* The mode of the register in which the argument is being passed.  */
index 8ff5be79e07db53882f70faa5b3d8ad44c8f739e..6b5dc8c5569bfda628a1eed4204fb1486a0e4703 100644 (file)
@@ -1,3 +1,11 @@
+2014-12-05  H.J. Lu  <hongjiu.lu@intel.com>
+
+       Backport from mainline
+       2014-11-28  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR rtl-optimization/64037
+       * g++.dg/pr64037.C: New test.
+
 2014-12-04  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/56493
diff --git a/gcc/testsuite/g++.dg/pr64037.C b/gcc/testsuite/g++.dg/pr64037.C
new file mode 100644 (file)
index 0000000..e5cd0e2
--- /dev/null
@@ -0,0 +1,27 @@
+// { dg-do run { target i?86-*-* x86_64-*-* } }
+// { dg-options "-std=c++11 -Os" }
+
+enum class X : unsigned char {
+  V = 2,
+};
+
+static void
+__attribute__((noinline,noclone))
+foo(unsigned &out, unsigned a, X b)
+{
+  out = static_cast<unsigned>(b);
+}
+
+int main()
+{
+  unsigned deadbeef = 0xDEADBEEF;
+  asm volatile ("" : "+d" (deadbeef), "+c" (deadbeef));
+
+  unsigned out;
+  foo(out, 2, X::V);
+
+  if (out != 2)
+    __builtin_abort ();
+
+  return 0;
+}