[llvm] SimplifyLibCalls: Use the correct address space when computing integer widths. (PR #118586)
Owen Anderson via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 4 16:26:48 PST 2024
================
@@ -590,26 +588,35 @@ Value *LibCallSimplifier::optimizeStrCmp(CallInst *CI, IRBuilderBase &B) {
if (Len1 && Len2) {
return copyFlags(
*CI, emitMemCmp(Str1P, Str2P,
- ConstantInt::get(DL.getIntPtrType(CI->getContext()),
- std::min(Len1, Len2)),
+ ConstantInt::get(
+ DL.getIntPtrType(
+ CI->getContext(),
+ Str1P->getType()->getPointerAddressSpace()),
+ std::min(Len1, Len2)),
----------------
resistor wrote:
> The reason getSizeTSize() unconditionally queries addrspace(0) is just that there aren't any in-tree targets where it needs to return anything else. Fixes welcome.
Honestly, I don't think fixing `getSizeTSize()` makes sense. It's just a wrapper around `DataLayout::getPointerSizeInBits`, which is already more widely accessible throughout the middle-end than `TargetLibraryInfo` is.
If we really want the convenience name, then I think we should move `getSizeTSize` to `DataLayout`, and add an addrspace argument such that it is a pure wrapper around `getPointerSizeInBits`.
https://github.com/llvm/llvm-project/pull/118586
More information about the llvm-commits
mailing list