This is an archive of the discontinued LLVM Phabricator instance.

[clang] Short-circuit evaluation in ::EvaluateAsConstantExpr
ClosedPublic

Authored by tbaeder on Nov 16 2022, 3:56 AM.

Details

Summary

This adds another case to FastEvaluateAsRValue() for boolean expressions as well as calls FastEvaluateAsRValue() in Expr::EvaluateAsConstantExpr() as well.

This way we can short-circuit evaluating simple integer and boolean literals here.

I don't have before/after numbers for compilation times, since my local builds have asan enabled (so valgrind doesn't work) and I lost access to the my asan-less build. But it shouldn't be worse than before... right?

Sorry, can't find better reviewers to add.

Diff Detail

Event Timeline

tbaeder created this revision.Nov 16 2022, 3:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 16 2022, 3:56 AM
tbaeder requested review of this revision.Nov 16 2022, 3:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 16 2022, 3:56 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
erichkeane accepted this revision.Nov 16 2022, 6:14 AM

This seems to make sense to me. I'll accept, but please give others time to take a look.

This revision is now accepted and ready to land.Nov 16 2022, 6:14 AM