public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [libgcc] Protect __TMC_END__ - __TMC_LIST__ == 0
@ 2016-10-27 10:25 Marc Glisse
  2016-11-04 14:08 ` Marc Glisse
  0 siblings, 1 reply; 4+ messages in thread
From: Marc Glisse @ 2016-10-27 10:25 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: TEXT/PLAIN, Size: 453 bytes --]

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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: TEXT/x-diff; name=tmc.patch, Size: 1349 bytes --]

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)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-11-20 13:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-27 10:25 [libgcc] Protect __TMC_END__ - __TMC_LIST__ == 0 Marc Glisse
2016-11-04 14:08 ` Marc Glisse
2016-11-04 14:47   ` Andrew Pinski
2016-11-20 13:37     ` Marc Glisse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).