[all-commits] [llvm/llvm-project] 861d69: [mlir] Speed up Lexer::getEncodedSourceLocation

River Riddle via All-commits all-commits at lists.llvm.org
Tue May 18 17:11:25 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 861d69a5259653f60d59795597493a7939b794fe
      https://github.com/llvm/llvm-project/commit/861d69a5259653f60d59795597493a7939b794fe
  Author: River Riddle <riddleriver at gmail.com>
  Date:   2021-05-18 (Tue, 18 May 2021)

  Changed paths:
    M mlir/lib/Parser/Lexer.cpp

  Log Message:
  -----------
  [mlir] Speed up Lexer::getEncodedSourceLocation

We currently use SourceMgr::getLineAndColumn to get the line and column for an SMLoc, but this includes a call to StringRef::find_last_of that ends up dominating compile time. In D102567, we start creating locations from the input file for block arguments which resulted in an extreme performance regression for modules with very large amounts of block arguments. This revision switches to just using a pointer offset from the beginning of the line to calculate the column(all MLIR files are simple ascii), resulting in a compile time reduction from 4700 seconds (1 hour and 18 minutes) to 8 seconds.

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




More information about the All-commits mailing list