summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MachineFunction.cpp
diff options
context:
space:
mode:
authorQuentin Colombet <qcolombet@apple.com>2016-08-26 22:32:53 +0000
committerQuentin Colombet <qcolombet@apple.com>2016-08-26 22:32:53 +0000
commit380cd3eb23ecc107d569e378ee5a69f26f4000ba (patch)
treea2be16bae4e69c53ae2c58f9a652f0a9736a3829 /llvm/lib/CodeGen/MachineFunction.cpp
parent39b6b2f0b0e71856eb17e0eb6ca84a35f0d2b7ab (diff)
downloadbcm5719-llvm-380cd3eb23ecc107d569e378ee5a69f26f4000ba.tar.gz
bcm5719-llvm-380cd3eb23ecc107d569e378ee5a69f26f4000ba.zip
[MachineFunction] Introduce a reset method.
This method allows to reset the state of a MachineFunction as if it was just created. This will be used during the bring-up of GlobalISel to provide a way to fallback on SelectionDAG. That way, we can start doing correctness testing even if we are not able to select all functions via the global instruction selector. llvm-svn: 279876
Diffstat (limited to 'llvm/lib/CodeGen/MachineFunction.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineFunction.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp
index f5c8147d859..08c93f20946 100644
--- a/llvm/lib/CodeGen/MachineFunction.cpp
+++ b/llvm/lib/CodeGen/MachineFunction.cpp
@@ -100,6 +100,11 @@ MachineFunction::MachineFunction(const Function *F, const TargetMachine &TM,
unsigned FunctionNum, MachineModuleInfo &mmi)
: Fn(F), Target(TM), STI(TM.getSubtargetImpl(*F)), Ctx(mmi.getContext()),
MMI(mmi) {
+ FunctionNumber = FunctionNum;
+ init();
+}
+
+void MachineFunction::init() {
// Assume the function starts in SSA form with correct liveness.
Properties.set(MachineFunctionProperties::Property::IsSSA);
Properties.set(MachineFunctionProperties::Property::TracksLiveness);
@@ -112,11 +117,11 @@ MachineFunction::MachineFunction(const Function *F, const TargetMachine &TM,
// We can realign the stack if the target supports it and the user hasn't
// explicitly asked us not to.
bool CanRealignSP = STI->getFrameLowering()->isStackRealignable() &&
- !F->hasFnAttribute("no-realign-stack");
+ !Fn->hasFnAttribute("no-realign-stack");
FrameInfo = new (Allocator) MachineFrameInfo(
getFnStackAlignment(STI, Fn), /*StackRealignable=*/CanRealignSP,
/*ForceRealign=*/CanRealignSP &&
- F->hasFnAttribute(Attribute::StackAlignment));
+ Fn->hasFnAttribute(Attribute::StackAlignment));
if (Fn->hasFnAttribute(Attribute::StackAlignment))
FrameInfo->ensureMaxAlignment(Fn->getFnStackAlignment());
@@ -133,15 +138,14 @@ MachineFunction::MachineFunction(const Function *F, const TargetMachine &TM,
if (AlignAllFunctions)
Alignment = AlignAllFunctions;
- FunctionNumber = FunctionNum;
JumpTableInfo = nullptr;
if (isFuncletEHPersonality(classifyEHPersonality(
- F->hasPersonalityFn() ? F->getPersonalityFn() : nullptr))) {
+ Fn->hasPersonalityFn() ? Fn->getPersonalityFn() : nullptr))) {
WinEHInfo = new (Allocator) WinEHFuncInfo();
}
- assert(TM.isCompatibleDataLayout(getDataLayout()) &&
+ assert(Target.isCompatibleDataLayout(getDataLayout()) &&
"Can't create a MachineFunction using a Module with a "
"Target-incompatible DataLayout attached\n");
@@ -149,6 +153,11 @@ MachineFunction::MachineFunction(const Function *F, const TargetMachine &TM,
}
MachineFunction::~MachineFunction() {
+ clear();
+}
+
+void MachineFunction::clear() {
+ Properties.reset();
// Don't call destructors on MachineInstr and MachineOperand. All of their
// memory comes from the BumpPtrAllocator which is about to be purged.
//
OpenPOWER on IntegriCloud