Author: evancheng Date: Fri Jan 18 12:35:18 2008 New Revision: 46164 URL: http://llvm.org/viewvc/llvm-project?rev=46164&view=rev Log: i32 / i64 all integer structs are not passed byval.
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=46164&r1=46163&r2=46164&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 Fri Jan 18 12:35:18 2008 @@ -62,13 +62,10 @@ } \ } -extern bool llvm_x86_is_zero_sized_aggregate(tree); -extern bool llvm_x86_64_should_pass_aggregate_in_memory(tree); +extern bool llvm_x86_should_pass_aggregate_in_memory(tree); #define LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(X) \ - (!llvm_x86_is_zero_sized_aggregate(X) && \ - (!TARGET_64BIT || \ - llvm_x86_64_should_pass_aggregate_in_memory(X))) + llvm_x86_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=46164&r1=46163&r2=46164&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 Jan 18 12:35:18 2008 @@ -664,23 +664,43 @@ 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. */ -bool llvm_x86_64_should_pass_aggregate_in_memory(tree type) { +static bool llvm_x86_64_should_pass_aggregate_in_memory(tree type, + enum machine_mode Mode){ int IntRegs, SSERegs; - enum machine_mode Mode = ix86_getNaturalModeForType(type); /* If ix86_HowToPassArgument return 0, then it's passed byval in memory.*/ return !ix86_HowToPassArgument(Mode, type, 0, &IntRegs, &SSERegs); } +/* Target hook for llvm-abi.h. It returns true if an aggregate of the + specified type should be passed in memory. */ +bool llvm_x86_should_pass_aggregate_in_memory(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); + + // Zero sized array, struct, or class, not passed in memory. + if (Bytes == 0) + return false; + + if (Bytes == GET_MODE_SIZE(SImode) || Bytes == GET_MODE_SIZE(DImode)) { + // 32-bit or 64-bit and all elements are integers, not passed in memory. + bool AllIntegers = true; + const Type *Ty = ConvertType(type); + for (Type::subtype_iterator I = Ty->subtype_begin(), E = Ty->subtype_end(); + I != E; ++I) + if (!I->get()->isIntOrIntVector()) { + AllIntegers = false; + break; + } + if (AllIntegers) + return false; + } + if (!TARGET_64BIT) + return true; + return llvm_x86_64_should_pass_aggregate_in_memory(type, Mode); +} + /* LLVM LOCAL end (ENTIRE FILE!) */ _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits