[llvm-commits] [124490] Workaround to fix functionarguments aligment on arm-linux-gnueabi.
echeng at apple.com
echeng at apple.com
Fri Mar 2 18:10:52 PST 2007
Revision: 124490
Author: echeng
Date: 2007-03-02 18:10:50 -0800 (Fri, 02 Mar 2007)
Log Message:
-----------
Workaround to fix functionarguments aligment on arm-linux-gnueabi.
Modified Paths:
--------------
apple-local/branches/llvm/gcc/llvm-abi.h
Modified: apple-local/branches/llvm/gcc/llvm-abi.h
===================================================================
--- apple-local/branches/llvm/gcc/llvm-abi.h 2007-03-03 01:27:27 UTC (rev 124489)
+++ apple-local/branches/llvm/gcc/llvm-abi.h 2007-03-03 02:10:50 UTC (rev 124490)
@@ -32,6 +32,7 @@
#include "llvm-internal.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
+#include "llvm/Target/TargetData.h"
namespace llvm {
class BasicBlock;
@@ -274,17 +275,31 @@
/// of the struct elements in.
void PassInIntegerRegisters(tree type, const Type *Ty) {
unsigned Size = TREE_INT_CST_LOW(TYPE_SIZE(type))/8;
-
+
+ // FIXME: We should preserve all aggregate value alignment information.
+ // Work around to preserve some aggregate value alignment information:
+ // don't bitcast aggregate value to Int64 if its alignment is different
+ // from Int64 alignment. ARM backend needs this.
+ unsigned Align = TYPE_ALIGN(type)/8;
+ unsigned Int64Align = getTargetData().getABITypeAlignment(Type::Int64Ty);
+ bool UseInt64 = (Align >= Int64Align);
+
// FIXME: In cases where we can, we should use the original struct.
// Consider cases like { int, int } and {int, short} for example! This will
// produce far better LLVM code!
std::vector<const Type*> Elts;
- for (; Size >= 8; Size -= 8)
- Elts.push_back(Type::Int64Ty);
- if (Size >= 4) {
- Elts.push_back(Type::Int32Ty);
- Size -= 4;
+ if (UseInt64) {
+ for (; Size >= 8; Size -= 8)
+ Elts.push_back(Type::Int64Ty);
+ if (Size >= 4) {
+ Elts.push_back(Type::Int32Ty);
+ Size -= 4;
+ }
+ } else {
+ for (; Size >= 4; Size -= 4)
+ Elts.push_back(Type::Int32Ty);
}
+
if (Size >= 2) {
Elts.push_back(Type::Int16Ty);
Size -= 2;
More information about the llvm-commits
mailing list