[llvm] SimplifyLibCalls: Use the correct address space when computing integer widths. (PR #118586)
Owen Anderson via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 5 00:49:32 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:
> For CHERI's purposes, shouldn't it be sufficient to consistently make use of getSizeTSize() in this file and patch getSizeTSize() to return the correct value? Maybe just making the default value be the index type size instead of the pointer type size would be sufficient?
I've split such a change into https://github.com/llvm/llvm-project/pull/118747
There seems to be at least one test that concretely tests for the opposite behavior today, so we'll need to sort that out. If we can make that change, then most of the changes in this PR become irrelevant.
https://github.com/llvm/llvm-project/pull/118586
More information about the llvm-commits
mailing list