Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions clang/lib/CodeGen/CGCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5346,13 +5346,14 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
// chosen IndirectAS can happen e.g. when passing the this pointer through
// a chain involving stores to / loads from the DefaultAS; we address this
// here, symmetrically with the handling we have for normal pointer args.
if (CGM.getCodeGenOpts().UseAllocaASForSrets &&
(SRetPtr.getAddressSpace() != RetAI.getIndirectAddrSpace())) {
unsigned RetAddrSpace = CGM.getCodeGenOpts().UseAllocaASForSrets
? RetAI.getIndirectAddrSpace()
: CGM.getTypes().getTargetAddressSpace(RetTy);
if (SRetPtr.getAddressSpace() != RetAddrSpace) {
llvm::Value *V = SRetPtr.getBasePointer();
LangAS SAS = getLangASFromTargetAS(SRetPtr.getAddressSpace());
LangAS DAS = getLangASFromTargetAS(RetAI.getIndirectAddrSpace());
llvm::Type *Ty = llvm::PointerType::get(getLLVMContext(),
RetAI.getIndirectAddrSpace());
LangAS DAS = getLangASFromTargetAS(RetAddrSpace);
llvm::Type *Ty = llvm::PointerType::get(getLLVMContext(), RetAddrSpace);

SRetPtr = SRetPtr.withPointer(
getTargetHooks().performAddrSpaceCast(*this, V, SAS, DAS, Ty, true),
Expand Down