-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[ADT] Always use 32-bit size type for SmallVector with 16-bit elements #95536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
SmallVector has a special case to allow vector of char to exceed 4 GB in size on 64-bit hosts. Apply this special case only for 8-bit element types, instead of all element types < 32 bits. This makes SmallVector<MCPhysReg> more compact because MCPhysReg is uint16_t.
@llvm/pr-subscribers-llvm-support @llvm/pr-subscribers-llvm-adt Author: Jay Foad (jayfoad) ChangesSmallVector has a special case to allow vector of char to exceed 4 GB in This makes SmallVector<MCPhysReg> more compact because MCPhysReg is Full diff: https://github.com/llvm/llvm-project/pull/95536.diff 1 Files Affected:
diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h
index 09676d792dfeb..d7e889cc7b1e4 100644
--- a/llvm/include/llvm/ADT/SmallVector.h
+++ b/llvm/include/llvm/ADT/SmallVector.h
@@ -116,8 +116,7 @@ template <class Size_T> class SmallVectorBase {
template <class T>
using SmallVectorSizeType =
- std::conditional_t<sizeof(T) < 4 && sizeof(void *) >= 8, uint64_t,
- uint32_t>;
+ std::conditional_t<sizeof(T) == 1, uintptr_t, uint32_t>;
/// Figure out the offset of the first element.
template <class T, typename = void> struct SmallVectorAlignmentAndSize {
|
Co-authored-by: Nikita Popov <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. To the best of my knowledge, the original motivation for this was specifically about the char/byte case, to support large binary blobs. If this is needed for other types, then we should have a mechanism to control it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add some tests for common types like char
, int16_t
, etc. (e.g., using std::is_same_v<T1, T2>
)
There were already some static_asserts for this kind of thing. I added one for int16_t. |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/23/builds/398 Here is the relevant piece of the build log for the reference:
|
This failure also happened on my other mac buildbot https://lab.llvm.org/buildbot/#/builders/190/builds/750 It didn't get automatically flagged because the host machine ran out of disk space which I am fixing up now. |
In llvm-project/llvm/include/llvm/ADT/SmallVector.h Lines 117 to 119 in 2582d11
But the llvm-project/llvm/lib/Support/SmallVector.cpp Lines 163 to 170 in 2582d11
On the arm64 Apple ABI, |
This is also breaking the GreenDragon macOS buildbots: https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6522/console |
Revert? |
Sure, just to unblock the bots while this gets looked into. |
… elements" (#96826) Reverts #95536, this is breaking macOS GreenDragon buildbots on arm64 and x86_64 https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6522/console, also breaks the Darwin LLVM buildbots: https://lab.llvm.org/buildbot/#/builders/23/builds/398
#95536) `SmallVector` has a special case to allow vector of char to exceed 4 GB in size on 64-bit hosts. Apply this special case only for 8-bit element types, instead of all element types < 32 bits. This makes `SmallVector<MCPhysReg>` more compact because `MCPhysReg` is `uint16_t`. --------- Co-authored-by: Nikita Popov <[email protected]>
… elements" (#96826) Reverts #95536, this is breaking macOS GreenDragon buildbots on arm64 and x86_64 https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6522/console, also breaks the Darwin LLVM buildbots: https://lab.llvm.org/buildbot/#/builders/23/builds/398
#95536) `SmallVector` has a special case to allow vector of char to exceed 4 GB in size on 64-bit hosts. Apply this special case only for 8-bit element types, instead of all element types < 32 bits. This makes `SmallVector<MCPhysReg>` more compact because `MCPhysReg` is `uint16_t`. --------- Co-authored-by: Nikita Popov <[email protected]>
… elements" (#96826) Reverts #95536, this is breaking macOS GreenDragon buildbots on arm64 and x86_64 https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6522/console, also breaks the Darwin LLVM buildbots: https://lab.llvm.org/buildbot/#/builders/23/builds/398
#95536) `SmallVector` has a special case to allow vector of char to exceed 4 GB in size on 64-bit hosts. Apply this special case only for 8-bit element types, instead of all element types < 32 bits. This makes `SmallVector<MCPhysReg>` more compact because `MCPhysReg` is `uint16_t`. --------- Co-authored-by: Nikita Popov <[email protected]>
… elements" (#96826) Reverts #95536, this is breaking macOS GreenDragon buildbots on arm64 and x86_64 https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6522/console, also breaks the Darwin LLVM buildbots: https://lab.llvm.org/buildbot/#/builders/23/builds/398
#95536) `SmallVector` has a special case to allow vector of char to exceed 4 GB in size on 64-bit hosts. Apply this special case only for 8-bit element types, instead of all element types < 32 bits. This makes `SmallVector<MCPhysReg>` more compact because `MCPhysReg` is `uint16_t`. --------- Co-authored-by: Nikita Popov <[email protected]>
… elements" (#96826) Reverts #95536, this is breaking macOS GreenDragon buildbots on arm64 and x86_64 https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6522/console, also breaks the Darwin LLVM buildbots: https://lab.llvm.org/buildbot/#/builders/23/builds/398
#95536) `SmallVector` has a special case to allow vector of char to exceed 4 GB in size on 64-bit hosts. Apply this special case only for 8-bit element types, instead of all element types < 32 bits. This makes `SmallVector<MCPhysReg>` more compact because `MCPhysReg` is `uint16_t`. --------- Co-authored-by: Nikita Popov <[email protected]>
… elements" (#96826) Reverts #95536, this is breaking macOS GreenDragon buildbots on arm64 and x86_64 https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6522/console, also breaks the Darwin LLVM buildbots: https://lab.llvm.org/buildbot/#/builders/23/builds/398
llvm#95536) `SmallVector` has a special case to allow vector of char to exceed 4 GB in size on 64-bit hosts. Apply this special case only for 8-bit element types, instead of all element types < 32 bits. This makes `SmallVector<MCPhysReg>` more compact because `MCPhysReg` is `uint16_t`. --------- Co-authored-by: Nikita Popov <[email protected]>
… elements" (llvm#96826) Reverts llvm#95536, this is breaking macOS GreenDragon buildbots on arm64 and x86_64 https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6522/console, also breaks the Darwin LLVM buildbots: https://lab.llvm.org/buildbot/#/builders/23/builds/398
#95536) `SmallVector` has a special case to allow vector of char to exceed 4 GB in size on 64-bit hosts. Apply this special case only for 8-bit element types, instead of all element types < 32 bits. This makes `SmallVector<MCPhysReg>` more compact because `MCPhysReg` is `uint16_t`. --------- Co-authored-by: Nikita Popov <[email protected]>
… elements" (#96826) Reverts #95536, this is breaking macOS GreenDragon buildbots on arm64 and x86_64 https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6522/console, also breaks the Darwin LLVM buildbots: https://lab.llvm.org/buildbot/#/builders/23/builds/398
llvm#95536) `SmallVector` has a special case to allow vector of char to exceed 4 GB in size on 64-bit hosts. Apply this special case only for 8-bit element types, instead of all element types < 32 bits. This makes `SmallVector<MCPhysReg>` more compact because `MCPhysReg` is `uint16_t`. --------- Co-authored-by: Nikita Popov <[email protected]>
… elements" (llvm#96826) Reverts llvm#95536, this is breaking macOS GreenDragon buildbots on arm64 and x86_64 https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6522/console, also breaks the Darwin LLVM buildbots: https://lab.llvm.org/buildbot/#/builders/23/builds/398
SmallVector
has a special case to allow vector of char to exceed 4 GB insize on 64-bit hosts. Apply this special case only for 8-bit element
types, instead of all element types < 32 bits.
This makes
SmallVector<MCPhysReg>
more compact becauseMCPhysReg
isuint16_t
.