]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Inline most functions in VG_(use_CF_info). May or may not give a
authorJulian Seward <jseward@acm.org>
Sun, 14 Mar 2010 17:19:02 +0000 (17:19 +0000)
committerJulian Seward <jseward@acm.org>
Sun, 14 Mar 2010 17:19:02 +0000 (17:19 +0000)
3% performance increase for Helgrind in default (detailed-history)
mode.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11093

coregrind/m_debuginfo/debuginfo.c
include/pub_tool_libcbase.h

index 9727cbce5b5028aad5159e9ece3b814652c0c6dc..2056ec2ab45f55797b21d56b319a0069491affcd 100644 (file)
@@ -1896,7 +1896,8 @@ typedef
 /* Evaluate the CfiExpr rooted at ix in exprs given the context eec.
    *ok is set to False on failure, but not to True on success.  The
    caller must set it to True before calling. */
-static 
+__attribute__((noinline))
+static
 UWord evalCfiExpr ( XArray* exprs, Int ix, 
                     CfiExprEvalContext* eec, Bool* ok )
 {
@@ -2079,7 +2080,7 @@ static void cfsi_cache__invalidate ( void ) {
 }
 
 
-static CFSICacheEnt* cfsi_cache__find ( Addr ip )
+static inline CFSICacheEnt* cfsi_cache__find ( Addr ip )
 {
    UWord         hash = ip % N_CFSI_CACHE;
    CFSICacheEnt* ce = &cfsi_cache[hash];
@@ -2108,6 +2109,7 @@ static CFSICacheEnt* cfsi_cache__find ( Addr ip )
 }
 
 
+inline
 static Addr compute_cfa ( D3UnwindRegs* uregs,
                           Addr min_accessible, Addr max_accessible,
                           DebugInfo* di, DiCfSI* cfsi )
@@ -2237,7 +2239,7 @@ Bool VG_(use_CF_info) ( /*MOD*/D3UnwindRegs* uregsHere,
       ML_(ppDiCfSI)(di->cfsi_exprs, cfsi);
    }
 
-   VG_(memset)(&uregsPrev, 0, sizeof(uregsPrev));
+   VG_(bzero_inline)(&uregsPrev, sizeof(uregsPrev));
 
    /* First compute the CFA. */
    cfa = compute_cfa(uregsHere,
index 0460112517431200a922725c1680a9ec5096cc6f..454db5a4416e1507dc181d5a74be4e85e9bc7f01 100644 (file)
@@ -110,6 +110,36 @@ extern void* VG_(memmove)( void *d, const void *s, SizeT sz );
 extern void* VG_(memset) ( void *s, Int c, SizeT sz );
 extern Int   VG_(memcmp) ( const void* s1, const void* s2, SizeT n );
 
+/* Zero out up to 8 words quickly in-line.  Do not use this for blocks
+   of size which are unknown at compile time, since the whole point is
+   for it to be inlined, and then for gcc to remove all code except
+   for the relevant 'sz' case. */
+inline __attribute__((always_inline))
+static void VG_(bzero_inline) ( void* s, SizeT sz )
+{
+   if (LIKELY(0 == (((Addr)sz) & (Addr)(sizeof(UWord)-1)))
+       && LIKELY(0 == (((Addr)s) & (Addr)(sizeof(UWord)-1)))) {
+      UWord* p = (UWord*)s;
+      switch (sz / (SizeT)sizeof(UWord)) {
+          case 8: p[0] = p[1] = p[2] = p[3]
+                  = p[4] = p[5] = p[6] = p[7] = 0UL; return;
+          case 7: p[0] = p[1] = p[2] = p[3]
+                  = p[4] = p[5] = p[6] = 0UL; return;
+          case 6: p[0] = p[1] = p[2] = p[3]
+                  = p[4] = p[5] = 0UL; return;
+          case 5: p[0] = p[1] = p[2] = p[3] = p[4] = 0UL; return;
+          case 4: p[0] = p[1] = p[2] = p[3] = 0UL; return;
+          case 3: p[0] = p[1] = p[2] = 0UL; return;
+          case 2: p[0] = p[1] = 0UL; return;
+          case 1: p[0] = 1; return;
+          case 0: return;
+          default: break;
+      }
+   }
+   VG_(memset)(s, 0, sz);
+}
+
+
 /* ---------------------------------------------------------------------
    Address computation helpers
    ------------------------------------------------------------------ */