[llvm-commits] [llvm-gcc-4.2] r52058 - in /llvm-gcc-4.2/trunk/gcc: config/i386/llvm-i386.cpp llvm-abi.h
Dale Johannesen
dalej at apple.com
Fri Jun 6 12:56:42 PDT 2008
Author: johannes
Date: Fri Jun 6 14:56:41 2008
New Revision: 52058
URL: http://llvm.org/viewvc/llvm-project?rev=52058&view=rev
Log:
X86-64 ABI: add handling for zero-length structs in C++.
These are padded to 1 byte, but are not passed the same
as normal 1-byte structs, nor as C zero-length structs.
Modified:
llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp
llvm-gcc-4.2/trunk/gcc/llvm-abi.h
Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp?rev=52058&r1=52057&r2=52058&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Fri Jun 6 14:56:41 2008
@@ -554,7 +554,12 @@
enum machine_mode Mode){
int IntRegs, SSERegs;
/* If ix86_HowToPassArgument return 0, then it's passed byval in memory.*/
- return !ix86_HowToPassArgument(Mode, TreeType, 0, &IntRegs, &SSERegs);
+ int ret = ix86_HowToPassArgument(Mode, TreeType, 0, &IntRegs, &SSERegs);
+ if (ret==0)
+ return true;
+ if (ret==1 && IntRegs==0 && SSERegs==0) // zero-sized struct
+ return true;
+ return false;
}
/* Returns true if all elements of the type are integer types. */
Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi.h?rev=52058&r1=52057&r2=52058&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-abi.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-abi.h Fri Jun 6 14:56:41 2008
@@ -449,12 +449,22 @@
} else if (TREE_CODE(type) == RECORD_TYPE) {
for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field))
if (TREE_CODE(Field) == FIELD_DECL) {
+ const tree Ftype = getDeclaredType(Field);
+ const Type *FTy = ConvertType(Ftype);
unsigned FNo = GetFieldIndex(Field);
assert(FNo != ~0U && "Case not handled yet!");
-
- C.EnterField(FNo, Ty);
- HandleArgument(getDeclaredType(Field), ScalarElts);
- C.ExitField();
+
+ // Currently, a bvyal type inside a non-byval struct is a zero-length
+ // object inside a bigger object on x86-64. This type should be
+ // skipped (but only when it is inside a bigger object).
+ // (We know there currently are no other such cases active because
+ // they would hit the assert in FunctionPrologArgumentConversion::
+ // HandleByValArgument.)
+ if (!LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(Ftype, FTy)) {
+ C.EnterField(FNo, Ty);
+ HandleArgument(getDeclaredType(Field), ScalarElts);
+ C.ExitField();
+ }
}
} else if (TREE_CODE(type) == COMPLEX_TYPE) {
C.EnterField(0, Ty);
More information about the llvm-commits
mailing list