From patchwork Mon Dec 19 19:30:39 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: PR middle-end/51411: handle transaction_safe virtual inlined methods Date: Mon, 19 Dec 2011 09:30:39 -0000 From: Aldy Hernandez X-Patchwork-Id: 132298 Message-Id: <4EEF90DF.7030801@redhat.com> To: Jason Merrill Cc: Patrick Marlier , Richard Henderson , gcc-patches >> Richard, Jason, are you ok with just unsetting DECL_WEAK? > > For now, yes. > >> I will come up with a suitable testcase for Patrick's case. > > Once there's a testcase, we can figure out why the other patch didn't work. > > Jason Hi Jason. I have made a testcase from Patrick's, and am committing the patch below. The first testcase tests the problem Patrick reports when we unset DECL_EXTERNAL and then we don't emit one of the clones. It is way beyond my template/C++/linking foo. I was hoping you could take a look at it. In the meantime, I am closing the PR as fixed. PR middle-end/51411 * trans-mem.c (ipa_tm_create_version): Unset DECL_WEAK. Index: testsuite/g++.dg/tm/pr51411-2.C =================================================================== --- testsuite/g++.dg/tm/pr51411-2.C (revision 0) +++ testsuite/g++.dg/tm/pr51411-2.C (revision 0) @@ -0,0 +1,49 @@ +// { dg-do compile } +// { dg-options "-fgnu-tm -O0" } + +namespace std { +template struct char_traits; + +template class allocator { +}; + +template struct less { + bool operator()(const _Tp& __x, const _Tp& __y) const { + return __x < __y; + } +}; + +template > class map { +public: + _Compare _M_key_compare; + bool find(const _Key& __x) { + return _M_key_compare(__x, __x); + } +}; + +template, typename _Alloc = allocator<_CharT> > class basic_string { +public: + bool compare(const basic_string& __str) const { + return 0; + } +}; + +typedef basic_string string; + +template +inline bool operator<(const basic_string<_CharT, _Traits>& __lhs, const basic_string<_CharT, _Traits>& __rhs) { + return __lhs.compare(__rhs); +} + +extern template class basic_string; + +} + +std::map units; + +__attribute__((transaction_callable)) +void get(const std::string &name) { + units.find(name); +} + +// { dg-final { scan-assembler "_ZGTtNKSs7compareERKSs:" } } Index: testsuite/g++.dg/tm/pr51411.C =================================================================== --- testsuite/g++.dg/tm/pr51411.C (revision 0) +++ testsuite/g++.dg/tm/pr51411.C (revision 0) @@ -0,0 +1,7 @@ +// { dg-do compile } +// { dg-options "-fgnu-tm -O" } + +struct A +{ + __attribute__ ((transaction_safe)) virtual void virtfoo () { } +}; Index: trans-mem.c =================================================================== --- trans-mem.c (revision 182491) +++ trans-mem.c (working copy) @@ -4260,6 +4260,7 @@ ipa_tm_create_version (struct cgraph_nod { DECL_EXTERNAL (new_decl) = 0; TREE_PUBLIC (new_decl) = 0; + DECL_WEAK (new_decl) = 0; } tree_function_versioning (old_decl, new_decl, NULL, false, NULL,