summaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/TargetLibraryInfo.cpp
diff options
context:
space:
mode:
authorMichael Kruse <llvm-project@meinersbur.de>2025-01-03 10:22:51 +0100
committerMichael Kruse <llvm-project@meinersbur.de>2025-01-03 10:22:51 +0100
commit38500d63e14ce340236840f60d356cdefb56a52c (patch)
tree17edbec446ce9b50d2f215a483b83afb293a635d /llvm/lib/Analysis/TargetLibraryInfo.cpp
parent1a3d5daaef7a6a63448a497da3eff7fc9e23df26 (diff)
parent27f30029741ecf023baece7b3dde1ff9011ffefc (diff)
Merge branch 'main' into users/meinersbur/flang_runtime_split-headersusers/meinersbur/flang_runtime_split-headers
Diffstat (limited to 'llvm/lib/Analysis/TargetLibraryInfo.cpp')
-rw-r--r--llvm/lib/Analysis/TargetLibraryInfo.cpp23
1 files changed, 10 insertions, 13 deletions
diff --git a/llvm/lib/Analysis/TargetLibraryInfo.cpp b/llvm/lib/Analysis/TargetLibraryInfo.cpp
index e0482b2b1ce0..8557901192e4 100644
--- a/llvm/lib/Analysis/TargetLibraryInfo.cpp
+++ b/llvm/lib/Analysis/TargetLibraryInfo.cpp
@@ -1459,19 +1459,16 @@ unsigned TargetLibraryInfoImpl::getWCharSize(const Module &M) const {
}
unsigned TargetLibraryInfoImpl::getSizeTSize(const Module &M) const {
- // There is really no guarantee that sizeof(size_t) is equal to sizeof(int*).
- // If that isn't true then it should be possible to derive the SizeTTy from
- // the target triple here instead and do an early return.
-
- // Historically LLVM assume that size_t has same size as intptr_t (hence
- // deriving the size from sizeof(int*) in address space zero). This should
- // work for most targets. For future consideration: DataLayout also implement
- // getIndexSizeInBits which might map better to size_t compared to
- // getPointerSizeInBits. Hard coding address space zero here might be
- // unfortunate as well. Maybe getDefaultGlobalsAddressSpace() or
- // getAllocaAddrSpace() is better.
- unsigned AddressSpace = 0;
- return M.getDataLayout().getPointerSizeInBits(AddressSpace);
+ // There is really no guarantee that sizeof(size_t) is equal to the index
+ // size of the default address space. If that isn't true then it should be
+ // possible to derive the SizeTTy from the target triple here instead and do
+ // an early return.
+
+ // Hard coding address space zero may seem unfortunate, but a number of
+ // configurations of common targets (i386, x86-64 x32, aarch64 x32, possibly
+ // others) have larger-than-size_t index sizes on non-default address spaces,
+ // making this the best default.
+ return M.getDataLayout().getIndexSizeInBits(/*AddressSpace=*/0);
}
TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass()