Skip to content

Conversation

@tbaederr
Copy link
Contributor

This adds support for array fillers, for global, toplevel descriptors.

Toplevel meaning that this gets an array filler:

constexpr int foo[200] = {1};

But this does not:

struct S { int i[10] = {3}; };
constexpr S s{};

For multidimensional arrays, only the topmost dimension gets an array filler:

constexpr float arr_f[3][5] = {
    {1, 2, 3, 4, 5},
};

This means that this patch fixes e.g.
test/SemaCXX/large-array-init, but does not fix
test/CodeGenCXX/cxx11-initializer-aggregate.cpp, as that contains arrays such as:

  struct B { int n; int arr[1024 * 1024 * 1024 * 2u]; } b = {1, {2}};
  // ...
  unsigned char data_3[1024][1024][1024] = {{{0}}};
  // ...
  unsigned char data_12[1024][1024][1024] = {{{1}}};

additionally, adding array fillers regresses performance in the common case of no array fillers:
https://llvm-compile-time-tracker.com/compare.php?from=02052caa09b27b422c452a2e1be2e3bfed710156&to=5b654212c1442d814aa8ed1c8de960432e479cdd&stat=instructions:u

This adds support for array fillers, for global, toplevel descriptors.

Toplevel meaning that this gets an array filler:
```c++
constexpr int foo[200] = {1};
```

But this does not:
```c++
struct S { int i[10] = {3}; };
constexpr S s{};
```

For multidimensional arrays, only the topmost dimension gets an array
filler:
```c++
constexpr float arr_f[3][5] = {
    {1, 2, 3, 4, 5},
};
```

This means that this patch fixes e.g.
`test/SemaCXX/large-array-init`, but does not fix
`test/CodeGenCXX/cxx11-initializer-aggregate.cpp`, as that contains
arrays such as:
```c++
  struct B { int n; int arr[1024 * 1024 * 1024 * 2u]; } b = {1, {2}};
  // ...
  unsigned char data_3[1024][1024][1024] = {{{0}}};
  // ...
  unsigned char data_12[1024][1024][1024] = {{{1}}};
```

additionally, adding array fillers regresses performance in the common
case of no array fillers:
https://llvm-compile-time-tracker.com/compare.php?from=02052caa09b27b422c452a2e1be2e3bfed710156&to=5b654212c1442d814aa8ed1c8de960432e479cdd&stat=instructions:u
@tbaederr tbaederr added clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:bytecode Issues for the clang bytecode constexpr interpreter labels Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:bytecode Issues for the clang bytecode constexpr interpreter clang:frontend Language frontend issues, e.g. anything involving "Sema"

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant