[llvm] TargetLibraryInfo: Use pointer index size to determine getSizeTSize(). (PR #118747)
Owen Anderson via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 5 13:47:28 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.
----------------
resistor wrote:
I don't think there's a huge difference in the approaches here. `getSizeTSize` already takes a `Module` argument specifically to enable target-specific overriding of the default behavior, but as of yet we don't have a target that can't be handle purely by the generic logic.
I'll address @arsenm's feedback and update the comment in this file to make it clear that targets may add overrides in this function.
https://github.com/llvm/llvm-project/pull/118747
More information about the llvm-commits
mailing list