Skip to content

Expr::getExprLoc() is slow #140876

@tbaederr

Description

@tbaederr

This first came up when the implementation of CallExpr::getBeginLoc() was changed and we saw a surprising drop in compile times.

We call Expr::getExprLoc() (and various other functions returning a SourceLocation) all the time. The assumption is that the call is cheap and that it's fine to do even if the source location isn't used in the end.

Changing the implementation of Expr::getExprLoc() to just return SourceLocation() improves compile times considerably: https://llvm-compile-time-tracker.com/compare.php?from=a71f56d63f569ca0ed543d3d01c684ca6ac7dffd&to=2510892ea46a84a284e0cde9f2a4edae3cdb183d&stat=instructions:u

tl;dr: Up to 15%.

Quick experiment with callgrind when compiling SemaExpr.cpp:

Image

We should improve this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"slow-compile

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions