[clang] [llvm] [Clang] Correct __builtin_dynamic_object_size for subobject types (PR #78526)
Bill Wendling via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 19 13:47:04 PST 2024
bwendling 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.
My patch only works with structs.
https://github.com/llvm/llvm-project/pull/78526
More information about the cfe-commits
mailing list