Params are not being generated as static globals now. The caller passes them onto the callee's stack directly and the callee loads the argvals from its own stack. Clang generated frameindexes validatd by recalculating the stack as if all frameindexes represent 1-byte slots.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68327 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/PIC16/PIC16AsmPrinter.cpp b/lib/Target/PIC16/PIC16AsmPrinter.cpp
index 3696d5a..6a5c2e0 100644
--- a/lib/Target/PIC16/PIC16AsmPrinter.cpp
+++ b/lib/Target/PIC16/PIC16AsmPrinter.cpp
@@ -335,6 +335,7 @@
void PIC16AsmPrinter::emitFunctionData(MachineFunction &MF) {
const Function *F = MF.getFunction();
std::string FuncName = Mang->getValueName(F);
+ MachineFrameInfo *MFI= MF.getFrameInfo();
Module *M = const_cast<Module *>(F->getParent());
const TargetData *TD = TM.getTargetData();
unsigned FrameSize = 0;
@@ -346,15 +347,30 @@
SectionFlags::Writeable);
SwitchToSection(fDataSection);
- //Emit function return value.
- O << CurrentFnName << ".retval:\n";
+
+ // Emit function frame label
+ O << CurrentFnName << ".frame:\n";
+
const Type *RetType = F->getReturnType();
unsigned RetSize = 0;
if (RetType->getTypeID() != Type::VoidTyID)
RetSize = TD->getTypePaddedSize(RetType);
- // Emit function arguments.
- O << CurrentFnName << ".args:\n";
+ //Emit function return value space
+ if(RetSize > 0)
+ O << CurrentFnName << ".retval RES " << RetSize << "\n";
+ else
+ O << CurrentFnName << ".retval:\n";
+
+ // Emit variable to hold the space for function arguments
+ unsigned ArgSize = 0;
+ for (Function::const_arg_iterator argi = F->arg_begin(),
+ arge = F->arg_end(); argi != arge ; ++argi) {
+ const Type *Ty = argi->getType();
+ ArgSize += TD->getTypePaddedSize(Ty);
+ }
+ O << CurrentFnName << ".args RES " << ArgSize << "\n";
+
// Emit the function variables.
// In PIC16 all the function arguments and local variables are global.
@@ -382,34 +398,15 @@
O << VarName << " RES " << Size << "\n";
}
- // Return value can not overlap with temp data, becasue a temp slot
- // may be read/written after a return value is calculated and saved
- // within the function.
- if (RetSize > FrameSize)
- O << CurrentFnName << ".dummy" << " RES " << (RetSize - FrameSize) << "\n";
- emitFunctionTempData(MF, FrameSize);
-}
-
-void PIC16AsmPrinter::emitFunctionTempData(MachineFunction &MF,
- unsigned &FrameSize) {
- // Emit temporary variables.
- MachineFrameInfo *FrameInfo = MF.getFrameInfo();
- if (FrameInfo->hasStackObjects()) {
- int indexBegin = FrameInfo->getObjectIndexBegin();
- int indexEnd = FrameInfo->getObjectIndexEnd();
-
- if (indexBegin < indexEnd) {
- FrameSize += indexEnd - indexBegin;
- O << CurrentFnName << ".tmp RES"<< " "
- <<indexEnd - indexBegin <<"\n";
- }
- /*
- while (indexBegin < indexEnd) {
- O << CurrentFnName << "_tmp_" << indexBegin << " " << "RES"<< " "
- << 1 << "\n" ;
- indexBegin++;
+ // Emit the variable to hold the space for temporary locations
+ // in function frame.
+ if (MFI->hasStackObjects()) {
+ int indexBegin = MFI->getObjectIndexBegin();
+ int indexEnd = MFI->getObjectIndexEnd();
+ if (indexBegin < indexEnd) {
+ int TempSize = indexEnd - indexBegin;
+ O << CurrentFnName << ".tmp RES " << TempSize <<"\n";
}
- */
}
}