COFF: Move a call to toString() out of the hot path.
authorPeter Collingbourne <peter@pcc.me.uk>
Fri, 9 Dec 2016 20:51:33 +0000 (20:51 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Fri, 9 Dec 2016 20:51:33 +0000 (20:51 +0000)
Profiling revealed that we were spending 5% of our time linking
chrome_child.dll just in this call to toString().

Differential Revision: https://reviews.llvm.org/D27628

llvm-svn: 289270

lld/COFF/InputFiles.cpp

index 087d7e2..d2146c2 100644 (file)
@@ -171,8 +171,10 @@ void ObjectFile::initializeSymbols() {
   int32_t LastSectionNumber = 0;
   for (uint32_t I = 0; I < NumSymbols; ++I) {
     // Get a COFFSymbolRef object.
-    COFFSymbolRef Sym =
-        check(COFFObj->getSymbol(I), "broken object file: " + toString(this));
+    ErrorOr<COFFSymbolRef> SymOrErr = COFFObj->getSymbol(I);
+    if (!SymOrErr)
+      fatal(SymOrErr.getError(), "broken object file: " + toString(this));
+    COFFSymbolRef Sym = *SymOrErr;
 
     const void *AuxP = nullptr;
     if (Sym.getNumberOfAuxSymbols())