Skip to content

Commit b209d67

Browse files
committed
Add query for a possible target specific indirect arg AS.
1 parent 6d9cb89 commit b209d67

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

clang/include/clang/Basic/TargetInfo.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1780,6 +1780,14 @@ class TargetInfo : public TransferrableTargetInfo,
17801780
return 0;
17811781
}
17821782

1783+
/// \returns Target specific address space for indirect (e.g. sret) arguments.
1784+
/// If such an address space exists, it must be convertible to and from the
1785+
/// alloca address space. If it does not, std::nullopt is returned and the
1786+
/// alloca address space will be used.
1787+
virtual std::optional<unsigned> getIndirectArgAddressSpace() const {
1788+
return std::nullopt;
1789+
}
1790+
17831791
/// \returns If a target requires an address within a target specific address
17841792
/// space \p AddressSpace to be converted in order to be used, then return the
17851793
/// corresponding target specific DWARF address space.

clang/lib/CodeGen/CGCall.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,9 +1672,11 @@ CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI) {
16721672

16731673
// Add type for sret argument.
16741674
if (IRFunctionArgs.hasSRetArg()) {
1675-
unsigned AddressSpace = CGM.getDataLayout().getAllocaAddrSpace();
1675+
auto AddressSpace = CGM.getTarget().getIndirectArgAddressSpace();
1676+
if (!AddressSpace)
1677+
AddressSpace = getDataLayout().getAllocaAddrSpace();
16761678
ArgTypes[IRFunctionArgs.getSRetArgNo()] =
1677-
llvm::PointerType::get(getLLVMContext(), AddressSpace);
1679+
llvm::PointerType::get(getLLVMContext(), *AddressSpace);
16781680
}
16791681

16801682
// Add type for inalloca argument.

0 commit comments

Comments
 (0)