aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/Sparc
diff options
context:
space:
mode:
authorBrian Gaeke <gaeke@uiuc.edu>2004-11-21 03:35:22 +0000
committerBrian Gaeke <gaeke@uiuc.edu>2004-11-21 03:35:22 +0000
commit79fe8334111f47c28100cd6729b66910ffbb40bf (patch)
treeb00f84f29d807a8f08cc6d3f04c007b1fb3b0d69 /lib/Target/Sparc
parente1e2899e96a4e813c35c4e4ca6b399c52e39b339 (diff)
downloadexternal_llvm-79fe8334111f47c28100cd6729b66910ffbb40bf.zip
external_llvm-79fe8334111f47c28100cd6729b66910ffbb40bf.tar.gz
external_llvm-79fe8334111f47c28100cd6729b66910ffbb40bf.tar.bz2
Fix extraStack calculation -- I think in fact it might be getting a bit *too*
much stack, but that's better than not enough, which leads to miscompilations. Fix FP vaarg. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18079 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/Sparc')
-rw-r--r--lib/Target/Sparc/SparcV8ISelSimple.cpp31
1 files changed, 22 insertions, 9 deletions
diff --git a/lib/Target/Sparc/SparcV8ISelSimple.cpp b/lib/Target/Sparc/SparcV8ISelSimple.cpp
index 771657a..eab7dd6 100644
--- a/lib/Target/Sparc/SparcV8ISelSimple.cpp
+++ b/lib/Target/Sparc/SparcV8ISelSimple.cpp
@@ -834,9 +834,9 @@ void V8ISel::visitCallInst(CallInst &I) {
}
}
- unsigned extraStack = 0;
// How much extra call stack will we need?
- for (unsigned i = 7; i < I.getNumOperands (); ++i) {
+ int extraStack = 0;
+ for (unsigned i = 0; i < I.getNumOperands (); ++i) {
switch (getClassB (I.getOperand (i)->getType ())) {
case cLong: extraStack += 8; break;
case cFloat: extraStack += 4; break;
@@ -844,8 +844,13 @@ void V8ISel::visitCallInst(CallInst &I) {
default: extraStack += 4; break;
}
}
- // Round up extra stack size to the nearest doubleword.
- if (extraStack) { extraStack = (extraStack + 7) & ~7; }
+ extraStack -= 24;
+ if (extraStack < 0) {
+ extraStack = 0;
+ } else {
+ // Round up extra stack size to the nearest doubleword.
+ extraStack = (extraStack + 7) & ~7;
+ }
// Deal with args
static const unsigned OutgoingArgRegs[] = { V8::O0, V8::O1, V8::O2, V8::O3,
@@ -1321,7 +1326,8 @@ void V8ISel::visitAllocaInst(AllocaInst &I) {
unsigned TmpReg2 = makeAnotherReg (Type::UIntTy);
unsigned StackAdjReg = makeAnotherReg (Type::UIntTy);
- // StackAdjReg = (ArraySize * TySize) rounded up to nearest doubleword boundary
+ // StackAdjReg = (ArraySize * TySize) rounded up to nearest
+ // doubleword boundary.
BuildMI (BB, V8::UMULrr, 2, TmpReg1).addReg (ArraySizeReg).addReg (TySizeReg);
// Round up TmpReg1 to nearest doubleword boundary:
@@ -1417,11 +1423,18 @@ void V8ISel::visitVAArgInst (VAArgInst &I) {
BuildMI (BB, V8::LD, 2, DestReg+1).addReg (VAList).addSImm (4);
return;
- case Type::FloatTyID:
- BuildMI (BB, V8::LDFri, 2, DestReg).addReg (VAList).addSImm (0);
+ case Type::DoubleTyID: {
+ unsigned DblAlign = TM.getTargetData().getDoubleAlignment();
+ unsigned TempReg = makeAnotherReg (Type::IntTy);
+ unsigned TempReg2 = makeAnotherReg (Type::IntTy);
+ int FI = F->getFrameInfo()->CreateStackObject(8, DblAlign);
+ BuildMI (BB, V8::LD, 2, TempReg).addReg (VAList).addSImm (0);
+ BuildMI (BB, V8::LD, 2, TempReg2).addReg (VAList).addSImm (4);
+ BuildMI (BB, V8::ST, 3).addFrameIndex (FI).addSImm (0).addReg (TempReg);
+ BuildMI (BB, V8::ST, 3).addFrameIndex (FI).addSImm (4).addReg (TempReg2);
+ BuildMI (BB, V8::LDDFri, 2, DestReg).addFrameIndex (FI).addSImm (0);
return;
-
- case Type::DoubleTyID:
+ }
default:
std::cerr << "Sorry, vaarg instruction of this type still unsupported:\n"