[llvm] SimplifyLibCalls: Use the correct address space when computing integer widths. (PR #118586)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 3 20:11:20 PST 2024


================
@@ -397,9 +397,11 @@ Value *LibCallSimplifier::emitStrLenMemCpy(Value *Src, Value *Dst, uint64_t Len,
 
   // We have enough information to now generate the memcpy call to do the
   // concatenation for us.  Make a memcpy to copy the nul byte with align = 1.
-  B.CreateMemCpy(
-      CpyDst, Align(1), Src, Align(1),
-      ConstantInt::get(DL.getIntPtrType(Src->getContext()), Len + 1));
+  B.CreateMemCpy(CpyDst, Align(1), Src, Align(1),
+                 ConstantInt::get(
+                     DL.getIntPtrType(Src->getContext(),
+                                      Src->getType()->getPointerAddressSpace()),
+                     Len + 1));
----------------
arsenm wrote:

Plus there should be a CreateMemCpy overload that uses a constant size and figures out the type for you

https://github.com/llvm/llvm-project/pull/118586


More information about the llvm-commits mailing list