[llvm-branch-commits] [clang] clang: Read the address space from the ABIArgInfo (PR #138865)
Matt Arsenault via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed May 7 13:08:45 PDT 2025
================
@@ -5384,16 +5384,16 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
if (!NeedCopy) {
// Skip the extra memcpy call.
llvm::Value *V = getAsNaturalPointerTo(Addr, I->Ty);
- auto *T = llvm::PointerType::get(
- CGM.getLLVMContext(), CGM.getDataLayout().getAllocaAddrSpace());
+ auto *T = llvm::PointerType::get(CGM.getLLVMContext(),
+ ArgInfo.getIndirectAddrSpace());
// FIXME: This should not depend on the language address spaces, and
// only the contextual values. If the address space mismatches, see if
// we can look through a cast to a compatible address space value,
// otherwise emit a copy.
----------------
arsenm wrote:
I mean this code doesn't understand the cast it is emitting. The language address space isn't particularly relevant, only whether the final IR value's target address space and the target ABI support the cast. The cast may not be supportable, regardless of the language mode. The existing logic just happens to work in the OpenCL case for existing targets. In general if we want to avoid the copy, we need to find the value at an existing compatible address, if not check if the cast is target legal and perform it, and then fallback no the copy. We're not checking if the cast is valid, and we don't perform the copy fallback
https://github.com/llvm/llvm-project/pull/138865
More information about the llvm-branch-commits
mailing list