diff options
| author | Anton Korobeynikov <asl@math.spbu.ru> | 2007-03-01 16:29:22 +0000 |
|---|---|---|
| committer | Anton Korobeynikov <asl@math.spbu.ru> | 2007-03-01 16:29:22 +0000 |
| commit | af8be4458fd0dc046703c1ce0012579c10563a36 (patch) | |
| tree | 0ed94c6d17b05efef4d46b1299a6e532b472883d /llvm/lib | |
| parent | 75ab9799df8817c455d4c9e028f2b9c7a7ea14cb (diff) | |
| download | bcm5719-llvm-af8be4458fd0dc046703c1ce0012579c10563a36.tar.gz bcm5719-llvm-af8be4458fd0dc046703c1ce0012579c10563a36.zip | |
Ensure that fastcall'ed function is correctly mangled & stack is
properly aligned
llvm-svn: 34788
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/X86/X86AsmPrinter.cpp | 6 | ||||
| -rw-r--r-- | llvm/lib/Target/X86/X86ISelLowering.cpp | 27 |
2 files changed, 20 insertions, 13 deletions
diff --git a/llvm/lib/Target/X86/X86AsmPrinter.cpp b/llvm/lib/Target/X86/X86AsmPrinter.cpp index 0e9171bb711..75003e6b748 100644 --- a/llvm/lib/Target/X86/X86AsmPrinter.cpp +++ b/llvm/lib/Target/X86/X86AsmPrinter.cpp @@ -49,10 +49,8 @@ static X86FunctionInfo calculateFunctionInfo(const Function *F, for (Function::const_arg_iterator AI = F->arg_begin(), AE = F->arg_end(); AI != AE; ++AI) - Size += TD->getTypeSize(AI->getType()); - - // Size should be aligned to DWORD boundary - Size = ((Size + 3)/4)*4; + // Size should be aligned to DWORD boundary + Size += ((TD->getTypeSize(AI->getType()) + 3)/4)*4; // We're not supporting tooooo huge arguments :) Info.setBytesToPopOnReturn((unsigned int)Size); diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index bbabc423ab5..65593ebb9bc 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -30,11 +30,16 @@ #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/SelectionDAG.h" #include "llvm/CodeGen/SSARegMap.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/MathExtras.h" #include "llvm/Target/TargetOptions.h" #include "llvm/ADT/StringExtras.h" using namespace llvm; +static cl::opt<bool> FastCallAlignStack("x86-fastcc-align-stack", cl::Hidden, + cl::desc("Align stack to 8-byte boundary for fastcall function"), + cl::init(false)); + X86TargetLowering::X86TargetLowering(TargetMachine &TM) : TargetLowering(TM) { Subtarget = &TM.getSubtarget<X86Subtarget>(); @@ -903,11 +908,13 @@ X86TargetLowering::LowerFastCCArguments(SDOperand Op, SelectionDAG &DAG) { ArgValues.push_back(Root); unsigned StackSize = CCInfo.getNextStackOffset(); - - // Make sure the instruction takes 8n+4 bytes to make sure the start of the - // arguments and the arguments after the retaddr has been pushed are aligned. - if ((StackSize & 7) == 0) - StackSize += 4; + + if (FastCallAlignStack) { + // Make sure the instruction takes 8n+4 bytes to make sure the start of the + // arguments and the arguments after the retaddr has been pushed are aligned. + if ((StackSize & 7) == 0) + StackSize += 4; + } VarArgsFrameIndex = 0xAAAAAAA; // fastcc functions can't have varargs. RegSaveFrameIndex = 0xAAAAAAA; // X86-64 only. @@ -936,10 +943,12 @@ SDOperand X86TargetLowering::LowerFastCCCallTo(SDOperand Op, SelectionDAG &DAG, // Get a count of how many bytes are to be pushed on the stack. unsigned NumBytes = CCInfo.getNextStackOffset(); - // Make sure the instruction takes 8n+4 bytes to make sure the start of the - // arguments and the arguments after the retaddr has been pushed are aligned. - if ((NumBytes & 7) == 0) - NumBytes += 4; + if (FastCallAlignStack) { + // Make sure the instruction takes 8n+4 bytes to make sure the start of the + // arguments and the arguments after the retaddr has been pushed are aligned. + if ((NumBytes & 7) == 0) + NumBytes += 4; + } Chain = DAG.getCALLSEQ_START(Chain,DAG.getConstant(NumBytes, getPointerTy())); |

