[MIR] Speedup parsing of function with large number of basic blocks
authorEvgeny Leviant <eleviant@accesssoftek.com>
Wed, 8 Jul 2020 15:50:00 +0000 (18:50 +0300)
committerEvgeny Leviant <eleviant@accesssoftek.com>
Wed, 8 Jul 2020 15:50:00 +0000 (18:50 +0300)
Patch eliminates string length calculation when lexing a token. Speedup can be up to
1000x.

Differential revision: https://reviews.llvm.org/D83389

llvm/lib/CodeGen/MIRParser/MIParser.cpp

index d6bf273..ded31cd 100644 (file)
@@ -563,7 +563,7 @@ MIParser::MIParser(PerFunctionMIParsingState &PFS, SMDiagnostic &Error,
 
 void MIParser::lex(unsigned SkipChar) {
   CurrentSource = lexMIToken(
-      CurrentSource.data() + SkipChar, Token,
+      CurrentSource.slice(SkipChar, StringRef::npos), Token,
       [this](StringRef::iterator Loc, const Twine &Msg) { error(Loc, Msg); });
 }