[all-commits] [llvm/llvm-project] b54294: [clang][ConstantEmitter] have tryEmitPrivate[ForVa...
Nick Desaulniers via All-commits
all-commits at lists.llvm.org
Mon Jul 24 13:51:12 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: b54294e2c9596088aaf557b221bcf471745864bc
https://github.com/llvm/llvm-project/commit/b54294e2c9596088aaf557b221bcf471745864bc
Author: Nick Desaulniers <ndesaulniers at google.com>
Date: 2023-07-24 (Mon, 24 Jul 2023)
Changed paths:
M clang/lib/AST/Expr.cpp
M clang/lib/AST/ExprConstant.cpp
M clang/lib/CodeGen/CGExprConstant.cpp
M clang/test/CodeGenCXX/const-init-cxx11.cpp
M clang/test/CodeGenCXX/const-init-cxx1y.cpp
M clang/test/CodeGenOpenCL/amdgpu-nullptr.cl
Log Message:
-----------
[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
More information about the All-commits
mailing list