[PATCH] include/llvm/Object/ELF.h: do debug checks only when NDEBUG

Dmitry Vyukov dvyukov at google.com
Thu Feb 14 03:02:21 PST 2013


validateSymbol() is called all over the place, and it seems it's a debug check.
It significantly speedups llvm-symbolizer used in tsan/asan/msan. validateSymbol() is the second hot function and accounts for 15% of runtime.


http://llvm-reviews.chandlerc.com/D408

Files:
  include/llvm/Object/ELF.h

Index: include/llvm/Object/ELF.h
===================================================================
--- include/llvm/Object/ELF.h
+++ include/llvm/Object/ELF.h
@@ -867,6 +867,7 @@
 
 template<class ELFT>
 void ELFObjectFile<ELFT>::validateSymbol(DataRefImpl Symb) const {
+#ifndef NDEBUG
   const Elf_Sym  *symb = getSymbol(Symb);
   const Elf_Shdr *SymbolTableSection = SymbolTableSections[Symb.d.b];
   // FIXME: We really need to do proper error handling in the case of an invalid
@@ -881,6 +882,7 @@
                    + SymbolTableSection->sh_size)))
     // FIXME: Proper error handling.
     report_fatal_error("Symb must point to a valid symbol!");
+#endif
 }
 
 template<class ELFT>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D408.1.patch
Type: text/x-patch
Size: 694 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130214/d7c8af38/attachment.bin>


More information about the llvm-commits mailing list