[llvm-branch-commits] [cfe-branch] r73440 - in /cfe/branches/Apple/Dib: lib/CodeGen/CGCall.cpp test/CodeGen/x86_64-arguments.c
Daniel Dunbar
daniel at zuster.org
Mon Jun 15 16:08:31 PDT 2009
Author: ddunbar
Date: Mon Jun 15 18:08:30 2009
New Revision: 73440
URL: http://llvm.org/viewvc/llvm-project?rev=73440&view=rev
Log:
Merge in 72419:
------------------------------------------------------------------------
r72419 | ddunbar | 2009-05-26 09:37:37 -0700 (Tue, 26 May 2009) | 10 lines
When trying to pass an argument on the stack, assume LLVM will do the right
thing for non-aggregate types.
- Otherwise we unnecessarily pin values to the stack and currently end up
triggering a backend bug in one case.
- This loose cooperation with LLVM to implement the ABI is pretty ugly.
- <rdar://problem/6918722> [irgen] clang miscompile of many pointer varargs on
x86-64
------------------------------------------------------------------------
Modified:
cfe/branches/Apple/Dib/lib/CodeGen/CGCall.cpp
cfe/branches/Apple/Dib/test/CodeGen/x86_64-arguments.c
Modified: cfe/branches/Apple/Dib/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/lib/CodeGen/CGCall.cpp?rev=73440&r1=73439&r2=73440&view=diff
==============================================================================
--- cfe/branches/Apple/Dib/lib/CodeGen/CGCall.cpp (original)
+++ cfe/branches/Apple/Dib/lib/CodeGen/CGCall.cpp Mon Jun 15 18:08:30 2009
@@ -575,6 +575,11 @@
const llvm::Type *CoerceTo,
ASTContext &Context) const;
+ /// getIndirectResult - Give a source type \arg Ty, return a suitable result
+ /// such that the argument will be passed in memory.
+ ABIArgInfo getIndirectResult(QualType Ty,
+ ASTContext &Context) const;
+
ABIArgInfo classifyReturnType(QualType RetTy,
ASTContext &Context) const;
@@ -875,6 +880,17 @@
return ABIArgInfo::getCoerce(CoerceTo);
}
+ABIArgInfo X86_64ABIInfo::getIndirectResult(QualType Ty,
+ ASTContext &Context) const {
+ // If this is a scalar LLVM value then assume LLVM will pass it in the right
+ // place naturally.
+ if (!CodeGenFunction::hasAggregateLLVMType(Ty))
+ return ABIArgInfo::getDirect();
+
+ // FIXME: Set alignment correctly.
+ return ABIArgInfo::getIndirect(0);
+}
+
ABIArgInfo X86_64ABIInfo::classifyReturnType(QualType RetTy,
ASTContext &Context) const {
// AMD64-ABI 3.2.3p4: Rule 1. Classify the return type with the
@@ -899,7 +915,7 @@
// AMD64-ABI 3.2.3p4: Rule 2. Types of class memory are returned via
// hidden argument.
case Memory:
- return ABIArgInfo::getIndirect(0);
+ return getIndirectResult(RetTy, Context);
// AMD64-ABI 3.2.3p4: Rule 3. If the class is INTEGER, the next
// available register of the sequence %rax, %rdx is used.
@@ -995,7 +1011,7 @@
// COMPLEX_X87, it is passed in memory.
case X87:
case ComplexX87:
- return ABIArgInfo::getIndirect(0);
+ return getIndirectResult(Ty, Context);
case SSEUp:
case X87Up:
@@ -1075,7 +1091,7 @@
freeIntRegs -= neededInt;
freeSSERegs -= neededSSE;
} else {
- it->info = ABIArgInfo::getIndirect(0);
+ it->info = getIndirectResult(it->type, Context);
}
}
}
Modified: cfe/branches/Apple/Dib/test/CodeGen/x86_64-arguments.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/test/CodeGen/x86_64-arguments.c?rev=73440&r1=73439&r2=73440&view=diff
==============================================================================
--- cfe/branches/Apple/Dib/test/CodeGen/x86_64-arguments.c (original)
+++ cfe/branches/Apple/Dib/test/CodeGen/x86_64-arguments.c Mon Jun 15 18:08:30 2009
@@ -61,4 +61,17 @@
struct s12 f12_0(void) {}
void f12_1(struct s12 a0) {}
+// RUN: grep 'define void @f14(.*, i8 signext .X)' %t &&
+void f14(int a, int b, int c, int d, int e, int f,
+ char X) {}
+// RUN: grep 'define void @f15(.*, i8\* .X)' %t &&
+void f15(int a, int b, int c, int d, int e, int f,
+ void *X) {}
+// RUN: grep 'define void @f16(.*, float .X)' %t &&
+void f16(float a, float b, float c, float d, float e, float f, float g, float h,
+ float X) {}
+// RUN: grep 'define void @f17(.*, x86_fp80 .X)' %t &&
+void f17(float a, float b, float c, float d, float e, float f, float g, float h,
+ long double X) {}
+
// RUN: true
More information about the llvm-branch-commits
mailing list