Page MenuHomePhabricator

[SourceMgr/MLIR diagnostics] Introduce a new method to speed things up
ClosedPublic

Authored by lattner on Apr 25 2020, 12:02 PM.

Details

Summary

This introduces a new SourceMgr::FindLocForLineAndColumn method that
uses the OffsetCache in SourceMgr::SrcBuffer to do do a constant time
lookup for the line number (once the cache is populated).

Use this method in MLIR's SourceMgrDiagnosticHandler::convertLocToSMLoc,
replacing the O(n) scanning logic. This resolves a long standing TODO
in MLIR, and makes one of my usecases go dramatically faster (which is
currently producing many diagnostics in a 40MB SourceBuffer).

NFC, this is just a performance speedup and cleanup.

Diff Detail

Event Timeline

lattner created this revision.Apr 25 2020, 12:02 PM
Herald added a reviewer: ftynse. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
rriddle accepted this revision.Apr 25 2020, 12:29 PM

Thank you for the review River!

This revision was not accepted when it landed; it landed in state Needs Review.Apr 25 2020, 2:20 PM
This revision was automatically updated to reflect the committed changes.