[llvm] TargetLibraryInfo: Use pointer index size to determine getSizeTSize(). (PR #118747)
Sergei Barannikov via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 5 22:28:12 PST 2024
================
@@ -1465,13 +1465,19 @@ unsigned TargetLibraryInfoImpl::getSizeTSize(const Module &M) const {
// 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.
+ // work for most targets. For future consideration: Hard coding address space
+ // zero here might be unfortunate. Maybe getMaxIndexSizeInBits() is better.
----------------
s-barannikov wrote:
My concern is not about customizability of this method. What I'm trying to say is that data layout methods may not return a reasonable default for `size_t` size (and it appears `getMaxIndexSizeInBits` doesn't). If `getMaxSizeInBits(0)` provides a better approximation, that suits me well. I could also live with `getLargestLegalIntTypeSizeInBits()` or `getStackAlignment().value() * 4` as long as they return the correct value :)
https://github.com/llvm/llvm-project/pull/118747
More information about the llvm-commits
mailing list