HomePhabricator

[Reland] [mlir] Speed up Lexer::getEncodedSourceLocation

Authored by rriddle on May 19 2021, 12:45 PM.

Description

[Reland] [mlir] Speed up Lexer::getEncodedSourceLocation

Reland Note: This was accidentally reverted in 80d981eda69f1ada6d944ed89571456cad13b850, but is an important improvement even outside of the driving motivator in D102567.

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.

Details

Committed
rriddleMay 19 2021, 12:57 PM
Parents
rG0bebda17bea3: [OpaquePtr] Make atomicrmw work with opaque pointers
Branches
Unknown
Tags
Unknown