This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[libgcc] Protect __TMC_END__ - __TMC_LIST__ == 0
- From: Marc Glisse <marc dot glisse at inria dot fr>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 27 Oct 2016 12:25:31 +0200 (CEST)
- Subject: [libgcc] Protect __TMC_END__ - __TMC_LIST__ == 0
- Authentication-results: sourceware.org; auth=none
Hello,
some optimization patch I was working on simplified __TMC_END__ -
__TMC_LIST__ == 0 to false, which is not wanted (I assume that's why it
wasn't written __TMC_END__ == __TMC_LIST__ in the first place).
Bootstrap+regtest on powerpc64le-unknown-linux-gnu.
2016-10-27 Marc Glisse <marc.glisse@inria.fr>
PR libgcc/77813
* crtstuff.c (deregister_tm_clones, register_tm_clones): Hide
__TMC_END__ behind a passthrough asm.
--
Marc Glisse
Index: libgcc/crtstuff.c
===================================================================
--- libgcc/crtstuff.c (revision 241611)
+++ libgcc/crtstuff.c (working copy)
@@ -273,41 +273,47 @@ STATIC func_ptr __TMC_LIST__[]
# ifdef HAVE_GAS_HIDDEN
extern func_ptr __TMC_END__[] __attribute__((__visibility__ ("hidden")));
# endif
static inline void
deregister_tm_clones (void)
{
void (*fn) (void *);
#ifdef HAVE_GAS_HIDDEN
- if (__TMC_END__ - __TMC_LIST__ == 0)
+ func_ptr *end = __TMC_END__;
+ // Do not optimize the comparison to false.
+ __asm ("" : "+g" (end));
+ if (__TMC_LIST__ == end)
return;
#else
if (__TMC_LIST__[0] == NULL)
return;
#endif
fn = _ITM_deregisterTMCloneTable;
__asm ("" : "+r" (fn));
if (fn)
fn (__TMC_LIST__);
}
static inline void
register_tm_clones (void)
{
void (*fn) (void *, size_t);
size_t size;
#ifdef HAVE_GAS_HIDDEN
- size = (__TMC_END__ - __TMC_LIST__) / 2;
+ func_ptr *end = __TMC_END__;
+ // Do not optimize the comparison to false.
+ __asm ("" : "+g" (end));
+ size = (end - __TMC_LIST__) / 2;
#else
for (size = 0; __TMC_LIST__[size * 2] != NULL; size++)
continue;
#endif
if (size == 0)
return;
fn = _ITM_registerTMCloneTable;
__asm ("" : "+r" (fn));
if (fn)