[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:11: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:
There's a few alternatives in here, none of them great:
* We can use the current state of this patch, which will have every target always use i64. As efriedma points out, this will probably work out because of backend legalization.
* We can thread TLI into `IRBuilder::CreateMemCpy` so that it can pick the right size. This requires updating a number of other passes throughout the tree, many of which don't depends on TargetLibraryInfo today.
* Same as above, but we add it in parallel to the existing overloads so that we can migrate users gradually.
* Build the types in SimplifyLibCalls as in the original version of this diff. Do some local cleanup to make it more readable per arsenm's feedback.
Thoughts?
https://github.com/llvm/llvm-project/pull/118586
More information about the llvm-commits
mailing list