[PATCH] D76096: [clang] allow const structs to be constant expressions in initializer lists
Richard Smith - zygoloid via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 13 13:29:22 PDT 2020
rsmith added a comment.
In D76096#1921842 <https://reviews.llvm.org/D76096#1921842>, @nickdesaulniers wrote:
> > The performance implications of deleting those lines is the complicated part.
>
> Where does compile time performance suffer from this? I guess if we have massive array initializers, or large struct definitions, or deeply nested struct definitions, it might take time to recursively evaluate if all members are constant expressions; but isn't that what I want as a developer, to offload the calculations to compile time rather than runtime? Or is the cost way too significant?
It's exactly what you suspect: very large global arrays initialized from constant data. For those, it's substantially more efficient for CodeGen to walk the AST representation (the `InitListExpr`) and directly generate an IR constant than it is to create an `APValue` representation of the array. (`APValue` is not especially space-efficient, and the extra copying and data shuffling can be quite slow.) We saw a significant compile time regression on a couple of LNT benchmarks without these early bailouts for C.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D76096/new/
https://reviews.llvm.org/D76096
More information about the cfe-commits
mailing list