[llvm-commits] CVS: llvm/lib/Target/X86/X86AsmPrinter.cpp X86ISelLowering.cpp
Anton Korobeynikov
asl at math.spbu.ru
Thu Mar 1 08:29:43 PST 2007
Changes in directory llvm/lib/Target/X86:
X86AsmPrinter.cpp updated: 1.234 -> 1.235
X86ISelLowering.cpp updated: 1.356 -> 1.357
---
Log message:
Ensure that fastcall'ed function is correctly mangled & stack is
properly aligned
---
Diffs of the changes: (+20 -13)
X86AsmPrinter.cpp | 6 ++----
X86ISelLowering.cpp | 27 ++++++++++++++++++---------
2 files changed, 20 insertions(+), 13 deletions(-)
Index: llvm/lib/Target/X86/X86AsmPrinter.cpp
diff -u llvm/lib/Target/X86/X86AsmPrinter.cpp:1.234 llvm/lib/Target/X86/X86AsmPrinter.cpp:1.235
--- llvm/lib/Target/X86/X86AsmPrinter.cpp:1.234 Tue Jan 30 02:04:53 2007
+++ llvm/lib/Target/X86/X86AsmPrinter.cpp Thu Mar 1 10:29:22 2007
@@ -49,10 +49,8 @@
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);
Index: llvm/lib/Target/X86/X86ISelLowering.cpp
diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.356 llvm/lib/Target/X86/X86ISelLowering.cpp:1.357
--- llvm/lib/Target/X86/X86ISelLowering.cpp:1.356 Wed Feb 28 12:39:53 2007
+++ llvm/lib/Target/X86/X86ISelLowering.cpp Thu Mar 1 10:29:22 2007
@@ -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 @@
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 @@
// 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()));
More information about the llvm-commits
mailing list