[clang] [llvm] [Clang] Correct __builtin_dynamic_object_size for subobject types (PR #78526)
Richard Smith via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 19 13:43:49 PST 2024
zygoloid wrote:
> For unions, clang will use the type of the union member with the largest size as the alloca type, regardless of which union member is active. I haven't tried, but your patch will probably compute the subobject size based on that arbitrarily picked member, rather than the one being accessed.
Another concrete case where using the IR type won't work is arrays whose initializer is mostly-zeroes. For example, for
```
int arr[20] = {[5] = 6};
```
we give `arr` the IR type `<{ i32, i32, i32, i32, i32, i32, [14 x i32] }>` so that we can use a `zeroinitializer` to fill the trailing portion of the array.
https://github.com/llvm/llvm-project/pull/78526
More information about the llvm-commits
mailing list