re PR ipa/64049 (r215898 caused wrong code at -O3)
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Mon, 8 Dec 2014 18:30:15 +0000 (18:30 +0000)
committerBernd Edlinger <edlinger@gcc.gnu.org>
Mon, 8 Dec 2014 18:30:15 +0000 (18:30 +0000)
2014-12-08  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        PR ipa/64049
        * ipa-polymorphic-call.c
        (pa_polymorphic_call_context::ipa_polymorphic_call): Allow RESULT_DECL.

testsuite/ChangeLog:
2014-12-08  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        PR ipa/64049
        * g++.dg/ipa/pr64049.h: New.
        * g++.dg/ipa/pr64049-1.C: New.
        * g++.dg/ipa/pr64049-2.C: New.

From-SVN: r218487

gcc/ChangeLog
gcc/ipa-polymorphic-call.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ipa/pr64049-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ipa/pr64049-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ipa/pr64049.h [new file with mode: 0644]

index 7591ec7ee1759af054b3f9c0b6afea51d0b2093a..edc26df8d153dba5dbeaf2a4db8db2150665615a 100644 (file)
@@ -1,3 +1,9 @@
+2014-12-08  Bernd Edlinger  <bernd.edlinger@hotmail.de>
+
+       PR ipa/64049
+       * ipa-polymorphic-call.c
+       (pa_polymorphic_call_context::ipa_polymorphic_call): Allow RESULT_DECL.
+
 2014-12-08  Alex Velenko  <Alex.Velenko@arm.com>
 
        * config/aarch64/aarch64.md (and_one_cmpl<mode>3_compare0_no_reuse):
index 6fed594269c7f662e35ba56cefe6451dff3cd7dc..bfd4bd4f0a537f45209b1df883c904c1a655556f 100644 (file)
@@ -1047,7 +1047,8 @@ ipa_polymorphic_call_context::ipa_polymorphic_call_context (tree fndecl,
 
   if (TREE_CODE (base_pointer) == SSA_NAME
       && SSA_NAME_IS_DEFAULT_DEF (base_pointer)
-      && TREE_CODE (SSA_NAME_VAR (base_pointer)) != PARM_DECL)
+      && !(TREE_CODE (SSA_NAME_VAR (base_pointer)) == PARM_DECL
+          || TREE_CODE (SSA_NAME_VAR (base_pointer)) == RESULT_DECL))
     {
       invalid = true;
       if (instance)
index 08289cca09106945cdbc251be2d3b37cd992397f..f47cfccdfaf77553f8de8233c3be34e7c82555ba 100644 (file)
@@ -1,3 +1,10 @@
+2014-12-08  Bernd Edlinger  <bernd.edlinger@hotmail.de>
+
+       PR ipa/64049
+       * g++.dg/ipa/pr64049.h: New.
+       * g++.dg/ipa/pr64049-1.C: New.
+       * g++.dg/ipa/pr64049-2.C: New.
+
 2014-12-08  Alex Velenko  <Alex.Velenko@arm.com>
 
        * gcc.target/aarch64/bics_3.c : New testcase.
diff --git a/gcc/testsuite/g++.dg/ipa/pr64049-1.C b/gcc/testsuite/g++.dg/ipa/pr64049-1.C
new file mode 100644 (file)
index 0000000..3b2d7b6
--- /dev/null
@@ -0,0 +1,37 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -fdump-ipa-inline" } */
+
+#include "pr64049.h"
+
+EnumStatusCode
+ValueHelper::getLocalizedText (const ValueStruct* pValueStruct, LocalizedText& target)
+{
+       if (pValueStruct && pValueStruct->dataType == 0 && pValueStruct->arrayType == 0)
+       {
+               _ASSERTION (pValueStruct->value.LocalizedText, "Unexpected null pointer");
+               return LocalizedTextSet (target.getInternHandle (), pValueStruct->value.LocalizedText);
+       }
+       else
+       {
+               return StatusCode::ERROR;
+       }
+}
+
+LocalizedText
+ValueHelper::getLocalizedText (const ValueStruct* pValueStruct)
+{
+       LocalizedText returnValue;
+       EnumStatusCode status = getLocalizedText (pValueStruct, returnValue);
+       _ASSERTION (StatusCode::isSUCCEEDED (status), "Conversion failed");
+       return returnValue;
+}
+
+EnumStatusCode
+LocalizedTextSet (LocalizedTextStruct* pTarget, LocalizedTextStruct* pSource)
+{
+       __builtin_strcpy (pTarget->getT (), pSource->getT ());
+       return StatusCode::SUCCESS;
+}
+
+/* { dg-final { scan-ipa-dump-not "__builtin_unreachable" "inline" } } */
+/* { dg-final { cleanup-ipa-dump "inline" } } */
diff --git a/gcc/testsuite/g++.dg/ipa/pr64049-2.C b/gcc/testsuite/g++.dg/ipa/pr64049-2.C
new file mode 100644 (file)
index 0000000..9449375
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-do run } */
+/* { dg-options "-O3 ${srcdir}/g++.dg/ipa/pr64049-1.C" } */
+
+#include "pr64049.h"
+
+int
+main ()
+{
+       ValueStruct v;
+       v.arrayType = 0;
+       v.dataType = 0;
+       v.value.LocalizedText = new LocalizedTextStruct ("Localized Text");
+       LocalizedText t = ValueHelper::getLocalizedText (&v);
+       if (__builtin_strcmp (t.getInternHandle ()->getT (), "Localized Text"))
+               __builtin_abort ();
+       return 0;
+}
+
+LocalizedTextStruct*
+LocalizedText::getInternHandle ()
+{
+       return &t;
+}
diff --git a/gcc/testsuite/g++.dg/ipa/pr64049.h b/gcc/testsuite/g++.dg/ipa/pr64049.h
new file mode 100644 (file)
index 0000000..9e28999
--- /dev/null
@@ -0,0 +1,53 @@
+#define _ASSERTION(expr, message) { if (!(expr)) __builtin_abort (); } (void)0
+
+typedef unsigned int EnumStatusCode;
+
+class StatusCode
+{
+public:
+       static const EnumStatusCode ERROR = 0x8000;
+       static const EnumStatusCode SUCCESS = 0x0000;
+       static bool isSUCCEEDED (EnumStatusCode res) { return (res == SUCCESS); }
+};
+
+class LocalizedTextStruct
+{
+public:
+       LocalizedTextStruct () {}
+       LocalizedTextStruct (const char *val)
+       {
+               __builtin_strcpy (t, val);
+       }
+       char *getT () { return t; }
+private:
+       char t[99];
+};
+
+typedef union tagValueUnion
+{
+       LocalizedTextStruct* LocalizedText;
+} ValueStructUnion;
+
+typedef struct ValueStruct
+{
+       unsigned char arrayType;
+       unsigned short dataType;
+       ValueStructUnion value;
+} ValueStruct;
+
+class LocalizedText
+{
+public:
+       virtual LocalizedTextStruct* getInternHandle ();
+private:
+       LocalizedTextStruct t;
+};
+
+class ValueHelper
+{
+public:
+       static EnumStatusCode getLocalizedText (const ValueStruct* pValueStruct, LocalizedText& target);
+       static LocalizedText getLocalizedText (const ValueStruct* pValueStruct);
+};
+
+EnumStatusCode LocalizedTextSet (LocalizedTextStruct* pTarget, LocalizedTextStruct* pSource);