r329513 - Generalize the swiftcall API since being passed indirectly isn't
John McCall via cfe-commits
cfe-commits at lists.llvm.org
Sat Apr 7 13:16:47 PDT 2018
Author: rjmccall
Date: Sat Apr 7 13:16:47 2018
New Revision: 329513
URL: http://llvm.org/viewvc/llvm-project?rev=329513&view=rev
Log:
Generalize the swiftcall API since being passed indirectly isn't
C++-specific anymore.
Modified:
cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h
cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp
Modified: cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h?rev=329513&r1=329512&r2=329513&view=diff
==============================================================================
--- cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h (original)
+++ cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h Sat Apr 7 13:16:47 2018
@@ -152,9 +152,15 @@ void legalizeVectorType(CodeGenModule &C
llvm::VectorType *vectorTy,
llvm::SmallVectorImpl<llvm::Type*> &types);
-/// Should a C++ record type be passed and returned indirectly?
-bool shouldPassCXXRecordIndirectly(CodeGenModule &CGM,
- const CXXRecordDecl *record);
+/// Is the given record type required to be passed and returned indirectly
+/// because of language restrictions?
+///
+/// This considers *only* mandatory indirectness due to language restrictions,
+/// such as C++'s non-trivially-copyable types and Objective-C's __weak
+/// references. A record for which this returns true may still be passed
+/// indirectly for other reasons, such as being too large to fit in a
+/// reasonable number of registers.
+bool mustPassRecordIndirectly(CodeGenModule &CGM, const RecordDecl *record);
/// Classify the rules for how to return a particular type.
ABIArgInfo classifyReturnType(CodeGenModule &CGM, CanQualType type);
@@ -166,7 +172,7 @@ ABIArgInfo classifyArgumentType(CodeGenM
/// private interface for Clang.
void computeABIInfo(CodeGenModule &CGM, CGFunctionInfo &FI);
-/// Is swifterror lowered to a register by the target ABI.
+/// Is swifterror lowered to a register by the target ABI?
bool isSwiftErrorLoweredInRegister(CodeGenModule &CGM);
} // end namespace swiftcall
Modified: cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp?rev=329513&r1=329512&r2=329513&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp (original)
+++ cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp Sat Apr 7 13:16:47 2018
@@ -740,8 +740,8 @@ void swiftcall::legalizeVectorType(CodeG
components.append(numElts, eltTy);
}
-bool swiftcall::shouldPassCXXRecordIndirectly(CodeGenModule &CGM,
- const CXXRecordDecl *record) {
+bool swiftcall::mustPassRecordIndirectly(CodeGenModule &CGM,
+ const RecordDecl *record) {
// FIXME: should we not rely on the standard computation in Sema, just in
// case we want to diverge from the platform ABI (e.g. on targets where
// that uses the MSVC rule)?
@@ -767,10 +767,8 @@ static ABIArgInfo classifyType(CodeGenMo
auto record = recordType->getDecl();
auto &layout = CGM.getContext().getASTRecordLayout(record);
- if (auto cxxRecord = dyn_cast<CXXRecordDecl>(record)) {
- if (shouldPassCXXRecordIndirectly(CGM, cxxRecord))
- return ABIArgInfo::getIndirect(layout.getAlignment(), /*byval*/ false);
- }
+ if (mustPassRecordIndirectly(CGM, record))
+ return ABIArgInfo::getIndirect(layout.getAlignment(), /*byval*/ false);
SwiftAggLowering lowering(CGM);
lowering.addTypedData(recordType->getDecl(), CharUnits::Zero(), layout);
More information about the cfe-commits
mailing list