[llvm-commits] [llvm-gcc-4.2] r95385 - in /llvm-gcc-4.2/trunk/gcc: llvm-abi-linux-ppc.cpp llvm-abi.h llvm-convert.cpp llvm-types.cpp
Rafael Espindola
rafael.espindola at gmail.com
Fri Feb 5 05:22:24 PST 2010
Author: rafael
Date: Fri Feb 5 07:22:23 2010
New Revision: 95385
URL: http://llvm.org/viewvc/llvm-project?rev=95385&view=rev
Log:
On linux ppc, don't use the inreg attribute to mark arguments that have to go to
memory. Use pad arguments instead.
I tested this with a llvm-gcc bootstrap + test-suite on linux x86-64 and with
test-suite run on linux pcc.
Thanks to Dale Johannesen for running the gcc compatibility tests on darwin
ppc.
Modified:
llvm-gcc-4.2/trunk/gcc/llvm-abi-linux-ppc.cpp
llvm-gcc-4.2/trunk/gcc/llvm-abi.h
llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
llvm-gcc-4.2/trunk/gcc/llvm-types.cpp
Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi-linux-ppc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi-linux-ppc.cpp?rev=95385&r1=95384&r2=95385&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-abi-linux-ppc.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-abi-linux-ppc.cpp Fri Feb 5 07:22:23 2010
@@ -65,16 +65,7 @@
/// _Complex arguments are never split, thus their two scalars are either
/// passed both in argument registers or both on the stack. Also _Complex
/// arguments are always passed in general purpose registers, never in
-/// Floating-point registers or vector registers. Arguments which should go
-/// on the stack are marked with the inreg parameter attribute.
-/// Giving inreg this target-dependent (and counter-intuitive) meaning
-/// simplifies things, because functions calls are not always coming from the
-/// frontend but are also created implicitly e.g. for libcalls. If inreg would
-/// actually mean that the argument is passed in a register, then all places
-/// which create function calls/function definitions implicitly would need to
-/// be aware of this fact and would need to mark arguments accordingly. With
-/// inreg meaning that the argument is passed on the stack, this is not an
-/// issue, except for calls which involve _Complex types.
+/// Floating-point registers or vector registers.
void SVR4ABI::HandleArgument(tree type, std::vector<const Type*> &ScalarElts,
Attributes *Attributes) {
unsigned Size = 0;
@@ -85,6 +76,7 @@
// Figure out if this field is zero bits wide, e.g. {} or [0 x int]. Do
// not include variable sized fields here.
std::vector<const Type*> Elts;
+ const Type* Int32Ty = Type::getInt32Ty(getGlobalContext());
if (Ty->isVoidTy()) {
// Handle void explicitly as an opaque type.
const Type *OpTy = OpaqueType::get(getGlobalContext());
@@ -99,8 +91,6 @@
if (NumGPR < NumArgRegs) {
NumGPR++;
- } else {
- Attr |= Attribute::InReg;
}
if (Attributes) {
@@ -121,9 +111,6 @@
ScalarElts.push_back(Ty);
}
} else if (Ty->isSingleValueType()) {
- C.HandleScalarArgument(Ty, type);
- ScalarElts.push_back(Ty);
-
unsigned Attr = Attribute::None;
if (Ty->isInteger()) {
@@ -137,19 +124,19 @@
// a register pair which starts with an odd register number.
if (TypeSize == 64 && (NumGPR % 2) == 1) {
NumGPR++;
+ C.HandlePad(Int32Ty);
}
if (NumGPR <= (NumArgRegs - NumRegs)) {
NumGPR += NumRegs;
} else {
- Attr |= Attribute::InReg;
+ for (unsigned int i = 0; i < NumArgRegs - NumGPR; ++i)
+ C.HandlePad(Int32Ty);
NumGPR = NumArgRegs;
}
} else if (isa<PointerType>(Ty)) {
if (NumGPR < NumArgRegs) {
NumGPR++;
- } else {
- Attr |= Attribute::InReg;
}
// We don't care about arguments passed in Floating-point or vector
// registers.
@@ -160,6 +147,9 @@
if (Attributes) {
*Attributes |= Attr;
}
+
+ C.HandleScalarArgument(Ty, type);
+ ScalarElts.push_back(Ty);
} else if (LLVM_SHOULD_PASS_AGGREGATE_AS_FCA(type, Ty)) {
C.HandleFCAArgument(Ty, type);
} else if (LLVM_SHOULD_PASS_AGGREGATE_IN_MIXED_REGS(type, Ty,
@@ -182,7 +172,8 @@
if (NumGPR == 0) {
NumGPR += NumArgRegs;
} else {
- Attr |= Attribute::InReg;
+ for (unsigned int i = 0; i < NumArgRegs - NumGPR; ++i)
+ C.HandlePad(Int32Ty);
NumGPR = NumArgRegs;
}
break;
@@ -192,7 +183,8 @@
if (NumGPR <= (NumArgRegs - 4)) {
NumGPR += 4;
} else {
- Attr |= Attribute::InReg;
+ for (unsigned int i = 0; i < NumArgRegs - NumGPR; ++i)
+ C.HandlePad(Int32Ty);
NumGPR = NumArgRegs;
}
break;
@@ -210,7 +202,8 @@
if (NumGPR <= (NumArgRegs - 2)) {
NumGPR += 2;
} else {
- Attr |= Attribute::InReg;
+ for (unsigned int i = 0; i < NumArgRegs - NumGPR; ++i)
+ C.HandlePad(Int32Ty);
NumGPR = NumArgRegs;
}
break;
@@ -220,8 +213,6 @@
// _Complex char
if (NumGPR < NumArgRegs) {
NumGPR++;
- } else {
- Attr |= Attribute::InReg;
}
break;
}
@@ -243,8 +234,6 @@
if (NumGPR < NumArgRegs) {
NumGPR++;
- } else {
- Attr |= Attribute::InReg;
}
if (Attributes) {
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=95385&r1=95384&r2=95385&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-abi.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-abi.h Fri Feb 5 07:22:23 2010
@@ -113,6 +113,7 @@
/// LLVM Struct, StructTy is the LLVM type of the struct we are entering.
virtual void EnterField(unsigned FieldNo, const llvm::Type *StructTy) {}
virtual void ExitField() {}
+ virtual void HandlePad(const llvm::Type *LLVMTy) {}
};
/// isAggregateTreeType - Return true if the specified GCC type is an aggregate
Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=95385&r1=95384&r2=95385&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Fri Feb 5 07:22:23 2010
@@ -267,6 +267,10 @@
/// getCallingConv - This provides the desired CallingConv for the function.
CallingConv::ID& getCallingConv(void) { return CallingConv; }
+ void HandlePad(const llvm::Type *LLVMTy) {
+ ++AI;
+ }
+
bool isShadowReturn() const {
return isShadowRet;
}
@@ -356,8 +360,7 @@
}
void HandleByValArgument(const llvm::Type *LLVMTy, tree type) {
- // Should not get here.
- abort();
+ ++AI;
}
void HandleFCAArgument(const llvm::Type *LLVMTy,
@@ -648,7 +651,7 @@
TheDebugInfo->EmitDeclare(Args, dwarf::DW_TAG_arg_variable,
Name, TREE_TYPE(Args),
AI, Builder);
- ++AI;
+ ABIConverter.HandleArgument(TREE_TYPE(Args), ScalarArgs);
} else {
// Otherwise, we create an alloca to hold the argument value and provide
// an l-value. On entry to the function, we copy formal argument values
@@ -2681,6 +2684,10 @@
isShadowRet = true;
}
+ void HandlePad(const llvm::Type *LLVMTy) {
+ CallOperands.push_back(UndefValue::get(LLVMTy));
+ }
+
/// HandleScalarShadowResult - This callback is invoked if the function
/// returns a scalar value by using a "shadow" first parameter, which is a
/// pointer to the scalar, of type PtrArgTy. If RetPtr is set to true,
Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=95385&r1=95384&r2=95385&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Fri Feb 5 07:22:23 2010
@@ -979,6 +979,10 @@
HandleShadowResult(PtrArgTy, RetPtr);
}
+ void HandlePad(const llvm::Type *LLVMTy) {
+ HandleScalarArgument(LLVMTy, 0, 0);
+ }
+
void HandleScalarArgument(const llvm::Type *LLVMTy, tree type,
unsigned RealSize = 0) {
if (KNRPromotion) {
More information about the llvm-commits
mailing list