Skip to content

Commit 54d8e3a

Browse files
committed
Switch to using getMaxIndexSizeInBits and improve comment
1 parent 945a97a commit 54d8e3a

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

llvm/lib/Analysis/TargetLibraryInfo.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,16 +1459,11 @@ unsigned TargetLibraryInfoImpl::getWCharSize(const Module &M) const {
14591459
}
14601460

14611461
unsigned TargetLibraryInfoImpl::getSizeTSize(const Module &M) const {
1462-
// There is really no guarantee that sizeof(size_t) is equal to sizeof(int*).
1463-
// If that isn't true then it should be possible to derive the SizeTTy from
1464-
// the target triple here instead and do an early return.
1465-
1466-
// Historically LLVM assume that size_t has same size as intptr_t (hence
1467-
// deriving the size from sizeof(int*) in address space zero). This should
1468-
// work for most targets. For future consideration: Hard coding address space
1469-
// zero here might be unfortunate. Maybe getMaxIndexSizeInBits() is better.
1470-
unsigned AddressSpace = 0;
1471-
return M.getDataLayout().getIndexSizeInBits(AddressSpace);
1462+
// The maximum index size over all address spaces is a reasonable default
1463+
// guess for size_t, but it cannot in general by derived by this. Per-target
1464+
// overrides should be added by reading the Module and/or the Triple to
1465+
// determine when this default doesn't apply.
1466+
return M.getDataLayout().getMaxIndexSizeInBits();
14721467
}
14731468

14741469
TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass()

0 commit comments

Comments
 (0)