[PATCH] D76096: [clang] allow const structs/unions/arrays to be constant expressions for C

2023-08-07 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance added a comment. In D76096#4564855 , @DavidSpickett wrote: > One of the kernel tests now fails to build for AArch64 and Arm: > > 00:00:48 ++ make > CC=/home/tcwg-buildslave/workspace/tcwg_kernel_0/bin/aarch64-cc >

[PATCH] D76096: [clang] allow const structs/unions/arrays to be constant expressions for C

2023-08-07 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added a comment. One of the kernel tests now fails to build for AArch64 and Arm: 00:00:48 ++ make CC=/home/tcwg-buildslave/workspace/tcwg_kernel_0/bin/aarch64-cc LD=/home/tcwg-buildslave/workspace/tcwg_kernel_0/llvm-install/bin/ld.lld SUBLEVEL=0 EXTRAVERSION=-bisect ARCH=arm64

[PATCH] D76096: [clang] allow const structs/unions/arrays to be constant expressions for C

2023-08-02 Thread Nick Desaulniers via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG610ec954e1f8: [clang] allow const structs/unions/arrays to be constant expressions for C (authored by nickdesaulniers). Repository: rG LLVM

[PATCH] D76096: [clang] allow const structs/unions/arrays to be constant expressions for C

2023-08-02 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision. efriedma added a comment. This revision is now accepted and ready to land. In D76096#4540442 , @nickdesaulniers wrote: > Consider the following code: > > long x [] = {1, 2, 3, 4, 5 + 4}; > > Even with some of my recent

[PATCH] D76096: [clang] allow const structs/unions/arrays to be constant expressions for C

2023-08-01 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments. Comment at: clang/docs/ReleaseNotes.rst:74-76 +- ``structs``, ``unions``, and ``arrays`` that are const may now be used as + constant expressions. This change is more consistent with the behavior of + GCC. Note to self:

[PATCH] D76096: [clang] allow const structs/unions/arrays to be constant expressions for C

2023-07-27 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment. In D76096#4537078 , @efriedma wrote: > The idea is to maintain the parallel infrastructure for structs and arrays, > but not for other things. Are you referring specifically to InitListExprs on VarDecls of records

[PATCH] D76096: [clang] allow const structs/unions/arrays to be constant expressions for C

2023-07-26 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment. > But prior to D151587 , we did that for C++. > Why is C special here? And prior to this patch, we did that for C++ 11+. Why > is C++ 03 special here? I'm trying to avoid regressions. C++11 made constant evaluation a lot more

[PATCH] D76096: [clang] allow const structs/unions/arrays to be constant expressions for C

2023-07-26 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment. In D76096#4533497 , @efriedma wrote: > Basically, I don't want order-of-magnitude compile-time regressions with > large global variables. There are basically two components to that: > > - That the fast path for emitting

[PATCH] D76096: [clang] allow const structs/unions/arrays to be constant expressions for C

2023-07-25 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment. Basically, I don't want order-of-magnitude compile-time regressions with large global variables. There are basically two components to that: - That the fast path for emitting globals in C continues be fast. - That we rarely end up using evaluateValue() on large global

[PATCH] D76096: [clang] allow const structs/unions/arrays to be constant expressions for C

2023-07-25 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 544128. nickdesaulniers added a comment. - rebase for presubmit builders Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D76096/new/ https://reviews.llvm.org/D76096 Files: clang/docs/ReleaseNotes.rst

[PATCH] D76096: [clang] allow const structs/unions/arrays to be constant expressions for C

2023-07-25 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment. what's the "exit criteria" for this patch (https://reviews.llvm.org/D76096)? in https://reviews.llvm.org/D76096#4523828 and https://reviews.llvm.org/D76096#4524003 you mention InitListExpr and StringLiteral. In https://reviews.llvm.org/D156185#4533274 I

[PATCH] D76096: [clang] allow const structs/unions/arrays to be constant expressions for C

2023-07-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment. Posting quick benchmarks of linux kernel builds: ac524886094db58112ca176e1d727330a94634a8 + D151587 + D76096 + D156154

[PATCH] D76096: [clang] allow const structs/unions/arrays to be constant expressions for C

2023-07-21 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment. > Is the idea for the way forward here to ensure (i.e. adding code such) that > ConstExprEmitter can constant evaluate such Expr's? For that exact construct, EvaluateAsRValue will also fail, so there's no real regression. The issue would be for a constant global

[PATCH] D76096: [clang] allow const structs/unions/arrays to be constant expressions for C

2023-07-21 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment. Hmm, that kind of construct could run into issues with large global variables. If we "inline" a bunch of large global constants into initializers for arrays, we could significantly increase codesize. Not sure how likely that is in practice. We could maybe consider

[PATCH] D76096: [clang] allow const structs/unions/arrays to be constant expressions for C

2023-07-21 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment. In D76096#4524092 , @nickdesaulniers wrote: > In D76096#4524003 , @efriedma wrote: > >> The ones most likely to be a concern are InitListExpr and StringLiteral. > > Here's a

[PATCH] D76096: [clang] allow const structs/unions/arrays to be constant expressions for C

2023-07-21 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment. In D76096#4524003 , @efriedma wrote: > The ones most likely to be a concern are InitListExpr and StringLiteral. Here's a reduced instance from the Linux kernel: struct timespec64 { long tv_sec; long tv_nsec;

[PATCH] D76096: [clang] allow const structs/unions/arrays to be constant expressions for C

2023-07-21 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment. The ones most likely to be a concern are InitListExpr and StringLiteral. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D76096/new/ https://reviews.llvm.org/D76096 ___

[PATCH] D76096: [clang] allow const structs/unions/arrays to be constant expressions for C

2023-07-21 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment. In D76096#4523828 , @efriedma wrote: > The idea would be looking for places we EvaluateAsRValue an array or struct. > Not sure what that stack trace represents. Perhaps you mean calling `EvaluateAsRValue` with a

[PATCH] D76096: [clang] allow const structs/unions/arrays to be constant expressions for C

2023-07-21 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment. The idea would be looking for places we EvaluateAsRValue an array or struct. Not sure what that stack trace represents. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D76096/new/ https://reviews.llvm.org/D76096

[PATCH] D76096: [clang] allow const structs/unions/arrays to be constant expressions for C

2023-07-21 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment. In D76096#4523750 , @nickdesaulniers wrote: > In D76096#4523718 , @efriedma wrote: > >> My primary concern here is making sure we don't actually blow up >> compile-time. D151587

[PATCH] D76096: [clang] allow const structs/unions/arrays to be constant expressions for C

2023-07-21 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 543051. nickdesaulniers added a comment. - use better identifiers in test - remove half baked comment from test Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D76096/new/ https://reviews.llvm.org/D76096

[PATCH] D76096: [clang] allow const structs/unions/arrays to be constant expressions for C

2023-07-21 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment. In D76096#4523718 , @efriedma wrote: > My primary concern here is making sure we don't actually blow up > compile-time. D151587 fixes the > dependency from CGExprConstant, which was

[PATCH] D76096: [clang] allow const structs/unions/arrays to be constant expressions for C

2023-07-21 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 543048. nickdesaulniers retitled this revision from "[clang] allow const structs to be constant expressions for C" to "[clang] allow const structs/unions/arrays to be constant expressions for C". nickdesaulniers added a comment. - add moar tests for