summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2009-03-23 23:26:24 +0000
committerEli Friedman <eli.friedman@gmail.com>2009-03-23 23:26:24 +0000
commit2dc5f29ff213b83448484bb953e8e915e4b40be7 (patch)
tree9b1b67bc1152b5f664046ee7e08bfe515ed4b820
parent1f0ce935e8c58f7862ea327b9c0245bc515008ec (diff)
downloadbcm5719-llvm-2dc5f29ff213b83448484bb953e8e915e4b40be7.tar.gz
bcm5719-llvm-2dc5f29ff213b83448484bb953e8e915e4b40be7.zip
Fix the ABI convention for struct returns on x86 outside of Darwin.
llvm-svn: 67577
-rw-r--r--clang/lib/CodeGen/CGCall.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index d7f52c6295e..8c438c9bd8c 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -251,6 +251,8 @@ class DefaultABIInfo : public ABIInfo {
/// X86_32ABIInfo - The X86-32 ABI information.
class X86_32ABIInfo : public ABIInfo {
+ bool IsDarwin;
+
public:
ABIArgInfo classifyReturnType(QualType RetTy,
ASTContext &Context) const;
@@ -267,6 +269,8 @@ public:
virtual llvm::Value *EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
CodeGenFunction &CGF) const;
+
+ X86_32ABIInfo(bool d) : ABIInfo(), IsDarwin(d) {}
};
}
@@ -275,6 +279,9 @@ ABIArgInfo X86_32ABIInfo::classifyReturnType(QualType RetTy,
if (RetTy->isVoidType()) {
return ABIArgInfo::getIgnore();
} else if (CodeGenFunction::hasAggregateLLVMType(RetTy)) {
+ // Outside of Darwin, structs and unions are always indirect.
+ if (!IsDarwin && !RetTy->isAnyComplexType())
+ return ABIArgInfo::getIndirect(0);
// Classify "single element" structs as their element type.
const FieldDecl *SeltFD = isSingleElementStruct(RetTy);
if (SeltFD) {
@@ -1183,9 +1190,10 @@ const ABIInfo &CodeGenTypes::getABIInfo() const {
// to free it.
const char *TargetPrefix = getContext().Target.getTargetPrefix();
if (strcmp(TargetPrefix, "x86") == 0) {
+ bool IsDarwin = strstr(getContext().Target.getTargetTriple(), "darwin");
switch (getContext().Target.getPointerWidth(0)) {
case 32:
- return *(TheABIInfo = new X86_32ABIInfo());
+ return *(TheABIInfo = new X86_32ABIInfo(IsDarwin));
case 64:
return *(TheABIInfo = new X86_64ABIInfo());
}
OpenPOWER on IntegriCloud