[PATCH] D155548: [clang][ExprConst] Short-circuit ConstantExpr evaluation

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 18 01:42:19 PDT 2023


tbaeder added a comment.

In D155548#4509056 <https://reviews.llvm.org/D155548#4509056>, @cor3ntin wrote:

> I think this does make sense. Have you notice an impact on performance?

No, but my local builds are debug builds and I have sanitizers enabled. 
When compiling the sqlite amalgamation, I see 1590 `ConstantExpr`s, 421 of which have their value already set.

> I wonder if there are places where we should cache the result of evaluating a ConstantExpr, like in `ExprEvaluatorBase::VisitConstantExpr`

I thought this happens elsewhere higher up the stack. E.g., in `Sema::VerifyIntegerConstantExpression`,

> How often do we construct a ConstantExpr without an initial computed value?

>From a quick check:

clang/lib/Sema/SemaExpr.cpp:7735:25
clang/lib/Sema/SemaExpr.cpp:17937:20
clang/lib/Sema/SemaExpr.cpp:18244:23
clang/lib/Sema/SemaExpr.cpp:20165:12

(That's the places using the `::Create` version without the value argument, I haven't checked `::CreateEmpty`).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D155548/new/

https://reviews.llvm.org/D155548



More information about the cfe-commits mailing list