[cherry-pick][stable/20230725] [lldb][DataFormatter] VectorType: fix format for arrays with size not a power-of-2 #7622
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
To get the number of children for a VectorType (i.e., a type declared with a
vector_size/ext_vector_typeattribute) LLDB previously did following calculation:getTypeInfo).unsigned char vec[16]as afloat32[]).numChildren = containerSize / reinterpretedElementSizeHowever, for step 1, clang will return us the aligned container byte-size.
So for a type such as
float __attribute__((ext_vector_type(3)))(which is an array of 3 4-byte floats), clang will round up the byte-width of the array to16.(see
here)
This means that for vectors where the size isn't a power-of-2, LLDB will miscalculate the number of elements.
Solution
This patch changes step 1 such that we calculate the container size as
numElementsInSource * byteSizeOfElement.(cherry picked from commit 0dfcfb5)