[llvm-commits] [llvm-gcc-4.2] r46157 - in /llvm-gcc-4.2/trunk/gcc/config/i386: llvm-i386-target.h llvm-i386.cpp
Evan Cheng
evan.cheng at apple.com
Thu Jan 17 17:47:03 PST 2008
Author: evancheng
Date: Thu Jan 17 19:47:03 2008
New Revision: 46157
URL: http://llvm.org/viewvc/llvm-project?rev=46157&view=rev
Log:
Do not pass zero sized array, struct, or class using byval attribute. This is true on both x86-32 and x86-64.
Modified:
llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h
llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp
Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h?rev=46157&r1=46156&r2=46157&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h (original)
+++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h Thu Jan 17 19:47:03 2008
@@ -62,10 +62,13 @@
} \
}
+extern bool llvm_x86_is_zero_sized_aggregate(tree);
extern bool llvm_x86_64_should_pass_aggregate_in_memory(tree);
#define LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(X) \
- (!TARGET_64BIT || llvm_x86_64_should_pass_aggregate_in_memory(X))
+ (!llvm_x86_is_zero_sized_aggregate(X) && \
+ (!TARGET_64BIT || \
+ llvm_x86_64_should_pass_aggregate_in_memory(X)))
/* LLVM LOCAL end (ENTIRE FILE!) */
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=46157&r1=46156&r2=46157&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 Thu Jan 17 19:47:03 2008
@@ -664,6 +664,15 @@
extern "C" enum machine_mode ix86_getNaturalModeForType(tree);
extern "C" int ix86_HowToPassArgument(enum machine_mode, tree, int, int*, int*);
+/* Target hook for llvm-abi.h. It returns true if the specified type is a
+ zero sized array, struct, or class. */
+bool llvm_x86_is_zero_sized_aggregate(tree type) {
+ enum machine_mode Mode = ix86_getNaturalModeForType(type);
+ HOST_WIDE_INT Bytes =
+ (Mode == BLKmode) ? int_size_in_bytes(type) : (int) GET_MODE_SIZE(Mode);
+ return Bytes == 0;
+}
+
/* Target hook for llvm-abi.h. It returns true if an aggregate of the
specified type should be passed in memory. This is only called for
x86-64. */
More information about the llvm-commits
mailing list