[clang][ConstantEmitter] have tryEmitPrivate[ForVarInit] try ConstExprEmitter fast-path first
As suggested by @efriedma in: https://reviews.llvm.org/D76096#4370369 This should speed up evaluating whether an expression is constant or not, but due to the complexity of these two different implementations, we may start getting different answers for edge cases for which we do not yet have test cases in-tree (or perhaps even performance regressions for some cases). As such, contributors have carte blanche to revert if necessary. For additional historical context about ExprConstant vs CGExprConstant, here's snippets from a private conversation on discord: ndesaulniers: why do we have clang/lib/AST/ExprConstant.cpp and clang/lib/CodeGen/CGExprConstant.cpp? Does clang constant fold during ast walking/creation AND during LLVM codegen? efriedma: originally, clang needed to handle two things: integer constant expressions (the "5" in "int x[5];"), and constant global initializers (the "5" in "int x = 5;"). pre-C++11, the two could be handled mostly separately; so we had the code for integer constants in AST/, and the code for globals in CodeGen/. C++11 constexpr sort of destroyed that separation, though. so now we do both kinds of constant evaluation on the AST, then CGExprConstant translates the result of that evaluation to LLVM IR. but we kept around some bits of the old cgexprconstant to avoid performance/memory usage regressions on large arrays. Reviewed By: efriedma Differential Revision: https://reviews.llvm.org/D151587
Loading
Please sign in to comment