Skip to content

Commit e8898a6

Browse files
authored
clang: Read the address space from the ABIArgInfo (#138865)
Do not assume it's the alloca address space, we have an explicit address space to use for the argument already. Also use the original value's type instead of assuming DefaultAS.
1 parent 416cdcf commit e8898a6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

clang/lib/CodeGen/CGCall.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5387,16 +5387,16 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
53875387
if (!NeedCopy) {
53885388
// Skip the extra memcpy call.
53895389
llvm::Value *V = getAsNaturalPointerTo(Addr, I->Ty);
5390-
auto *T = llvm::PointerType::get(
5391-
CGM.getLLVMContext(), CGM.getDataLayout().getAllocaAddrSpace());
5390+
auto *T = llvm::PointerType::get(CGM.getLLVMContext(),
5391+
ArgInfo.getIndirectAddrSpace());
53925392

53935393
// FIXME: This should not depend on the language address spaces, and
53945394
// only the contextual values. If the address space mismatches, see if
53955395
// we can look through a cast to a compatible address space value,
53965396
// otherwise emit a copy.
53975397
llvm::Value *Val = getTargetHooks().performAddrSpaceCast(
5398-
*this, V, LangAS::Default, CGM.getASTAllocaAddressSpace(), T,
5399-
true);
5398+
*this, V, I->Ty.getAddressSpace(), CGM.getASTAllocaAddressSpace(),
5399+
T, true);
54005400
if (ArgHasMaybeUndefAttr)
54015401
Val = Builder.CreateFreeze(Val);
54025402
IRCallArgs[FirstIRArg] = Val;

0 commit comments

Comments
 (0)