[llvm-commits] [llvm-gcc-4.2] r47759 - /llvm-gcc-4.2/trunk/gcc/llvm-abi.h
Dale Johannesen
dalej at apple.com
Fri Feb 29 11:11:16 PST 2008
Author: johannes
Date: Fri Feb 29 13:11:16 2008
New Revision: 47759
URL: http://llvm.org/viewvc/llvm-project?rev=47759&view=rev
Log:
Reducing a struct to the type of its single element
should be done only if their sizes are the same
(__aligned__ can create structs where this is not true)
Modified:
llvm-gcc-4.2/trunk/gcc/llvm-abi.h
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=47759&r1=47758&r2=47759&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-abi.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-abi.h Fri Feb 29 13:11:16 2008
@@ -187,6 +187,9 @@
// LLVM_SHOULD_RETURN_STRUCT_AS_SCALAR - Return a TYPE tree if this struct
// should be returned using the convention for that scalar TYPE, 0 otherwise.
+// The returned TYPE must be the same size as X for this to work; that is
+// checked elsewhere. (Structs where this is not the case can be constructed
+// by abusing the __aligned__ attribute.)
#ifndef LLVM_SHOULD_RETURN_STRUCT_AS_SCALAR
#define LLVM_SHOULD_RETURN_STRUCT_AS_SCALAR(X) \
isSingleElementStructOrArray(X, false, false)
@@ -219,7 +222,11 @@
// FIXME: this is a hack around returning 'complex double' by-val
// which returns in r3/r4/r5/r6 on PowerPC.
TREE_INT_CST_LOW(TYPE_SIZE_UNIT(type)) <= 8) {
- if (tree SingleElt = LLVM_SHOULD_RETURN_STRUCT_AS_SCALAR(type)) {
+ tree SingleElt = LLVM_SHOULD_RETURN_STRUCT_AS_SCALAR(type);
+ if (SingleElt && TYPE_SIZE(SingleElt) &&
+ TREE_CODE(TYPE_SIZE(SingleElt)) == INTEGER_CST &&
+ TREE_INT_CST_LOW(TYPE_SIZE_UNIT(type)) ==
+ TREE_INT_CST_LOW(TYPE_SIZE_UNIT(SingleElt))) {
C.HandleAggregateResultAsScalar(ConvertType(SingleElt));
} else {
// Otherwise return as an integer value large enough to hold the entire
More information about the llvm-commits
mailing list