From b09e592eeefde7c1e9159d69358314308b3cb350 Mon Sep 17 00:00:00 2001 From: Bernd Edlinger Date: Mon, 8 Dec 2014 18:30:15 +0000 Subject: [PATCH] re PR ipa/64049 (r215898 caused wrong code at -O3) 2014-12-08 Bernd Edlinger PR ipa/64049 * ipa-polymorphic-call.c (pa_polymorphic_call_context::ipa_polymorphic_call): Allow RESULT_DECL. testsuite/ChangeLog: 2014-12-08 Bernd Edlinger 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 | 6 ++++ gcc/ipa-polymorphic-call.c | 3 +- gcc/testsuite/ChangeLog | 7 ++++ gcc/testsuite/g++.dg/ipa/pr64049-1.C | 37 +++++++++++++++++++ gcc/testsuite/g++.dg/ipa/pr64049-2.C | 23 ++++++++++++ gcc/testsuite/g++.dg/ipa/pr64049.h | 53 ++++++++++++++++++++++++++++ 6 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/ipa/pr64049-1.C create mode 100644 gcc/testsuite/g++.dg/ipa/pr64049-2.C create mode 100644 gcc/testsuite/g++.dg/ipa/pr64049.h diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7591ec7ee17..edc26df8d15 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2014-12-08 Bernd Edlinger + + PR ipa/64049 + * ipa-polymorphic-call.c + (pa_polymorphic_call_context::ipa_polymorphic_call): Allow RESULT_DECL. + 2014-12-08 Alex Velenko * config/aarch64/aarch64.md (and_one_cmpl3_compare0_no_reuse): diff --git a/gcc/ipa-polymorphic-call.c b/gcc/ipa-polymorphic-call.c index 6fed594269c..bfd4bd4f0a5 100644 --- a/gcc/ipa-polymorphic-call.c +++ b/gcc/ipa-polymorphic-call.c @@ -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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 08289cca091..f47cfccdfaf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2014-12-08 Bernd Edlinger + + 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 * 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 index 00000000000..3b2d7b6b703 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr64049-1.C @@ -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 index 00000000000..94493753c82 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr64049-2.C @@ -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 index 00000000000..9e289993444 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr64049.h @@ -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); -- 2.30.2