[Stackmaps] Record the stack size of each function that contains a stackmap/patchpoint intrinsic.

Reviewed by Andy

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200444 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Juergen Ributzka
2014-01-30 03:06:14 +00:00
parent efdbec8b0a
commit 2baaf25bf5
6 changed files with 112 additions and 26 deletions

View File

@ -11,6 +11,8 @@
#include "llvm/CodeGen/StackMaps.h"
#include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/MC/MCContext.h"
@ -216,12 +218,19 @@ void StackMaps::recordStackMapOpers(const MachineInstr &MI, uint64_t ID,
}
}
// Create an expression to calculate the offset of the callsite from function
// entry.
const MCExpr *CSOffsetExpr = MCBinaryExpr::CreateSub(
MCSymbolRefExpr::Create(MILabel, OutContext),
MCSymbolRefExpr::Create(AP.CurrentFnSym, OutContext),
OutContext);
CSInfos.push_back(CallsiteInfo(CSOffsetExpr, ID, Locations, LiveOuts));
// Record the stack size of the current function.
const MachineFrameInfo *MFI = AP.MF->getFrameInfo();
FnStackSize[AP.CurrentFnSym] =
MFI->hasVarSizedObjects() ? ~0U : MFI->getStackSize();
}
void StackMaps::recordStackMap(const MachineInstr &MI) {
@ -258,6 +267,11 @@ void StackMaps::recordPatchPoint(const MachineInstr &MI) {
/// serializeToStackMapSection conceptually populates the following fields:
///
/// uint32 : Reserved (header)
/// uint32 : NumFunctions
/// StkSizeRecord[NumFunctions] {
/// uint32 : Function Offset
/// uint32 : Stack Size
/// }
/// uint32 : NumConstants
/// int64 : Constants[NumConstants]
/// uint32 : NumRecords
@ -313,6 +327,16 @@ void StackMaps::serializeToStackMapSection() {
// Header.
AP.OutStreamer.EmitIntValue(0, 4);
// Num functions.
AP.OutStreamer.EmitIntValue(FnStackSize.size(), 4);
// Stack size entries.
for (FnStackSizeMap::iterator I = FnStackSize.begin(), E = FnStackSize.end();
I != E; ++I) {
AP.EmitLabelReference(I->first, 4, true);
AP.OutStreamer.EmitIntValue(I->second, 4);
}
// Num constants.
AP.OutStreamer.EmitIntValue(ConstPool.getNumConstants(), 4);