75#define DEBUG_TYPE "cfi-fixup"
80 "Insert CFI remember/restore state instructions",
false,
false)
84 return MI.getOpcode() == TargetOpcode::CFI_INSTRUCTION &&
94 return MI.getOpcode() == TargetOpcode::CFI_INSTRUCTION &&
110 bool StrongNoFrameOnEntry : 1;
111 bool HasFrameOnEntry : 1;
112 bool HasFrameOnExit : 1;
115 BlockInfo[0].Reachable =
true;
116 BlockInfo[0].StrongNoFrameOnEntry =
true;
126 bool HasPrologue =
false;
127 bool HasEpilogue =
false;
134 if (
Info.HasFrameOnEntry || HasPrologue)
140 Info.HasFrameOnExit = (
Info.HasFrameOnEntry || HasPrologue) && !HasEpilogue;
144 BlockFlags &SuccInfo = BlockInfo[Succ->getNumber()];
145 SuccInfo.Reachable =
true;
146 SuccInfo.StrongNoFrameOnEntry |=
147 Info.StrongNoFrameOnEntry && !HasPrologue;
148 SuccInfo.HasFrameOnEntry =
Info.HasFrameOnExit;
168 InsertPt = std::next(
MI.getIterator());
171 "Inconsistent notion of \"prologue block\"");
177 bool HasFrame = BlockInfo[PrologueBlock->
getNumber()].HasFrameOnExit;
178 while (CurrBB != MF.
end()) {
179 const BlockFlags &
Info = BlockInfo[CurrBB->getNumber()];
180 if (!
Info.Reachable) {
186 if (!
Info.StrongNoFrameOnEntry) {
187 for (
auto *Pred : CurrBB->predecessors()) {
188 BlockFlags &PredInfo = BlockInfo[Pred->getNumber()];
189 assert((!PredInfo.Reachable ||
190 Info.HasFrameOnEntry == PredInfo.HasFrameOnExit) &&
191 "Inconsistent call frame state");
195 if (!
Info.StrongNoFrameOnEntry &&
Info.HasFrameOnEntry && !HasFrame) {
203 TII.get(TargetOpcode::CFI_INSTRUCTION))
208 TII.get(TargetOpcode::CFI_INSTRUCTION))
211 InsertMBB = &*CurrBB;
213 }
else if ((
Info.StrongNoFrameOnEntry || !
Info.HasFrameOnEntry) &&
220 HasFrame =
Info.HasFrameOnExit;
static bool containsPrologue(const MachineBasicBlock &MBB)
static bool isPrologueCFIInstruction(const MachineInstr &MI)
static bool containsEpilogue(const MachineBasicBlock &MBB)
Contains definition of the base CFIFixup pass.
Analysis containing CSE Info
const HexagonInstrInfo * TII
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This file builds on the ADT/GraphTraits.h file to build a generic graph post order iterator.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file implements the SmallBitVector class.
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
FunctionPass class - This class is used to implement most global optimizations.
static MCCFIInstruction createRememberState(MCSymbol *L, SMLoc Loc={})
.cfi_remember_state Save all current rules for all registers.
static MCCFIInstruction createRestoreState(MCSymbol *L, SMLoc Loc={})
.cfi_restore_state Restore the previously saved state.
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
iterator_range< succ_iterator > successors()
unsigned addFrameInst(const MCCFIInstruction &Inst)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
unsigned getNumBlockIDs() const
getNumBlockIDs - Return the number of MBB ID's allocated.
const MachineInstrBuilder & addCFIIndex(unsigned CFIIndex) const
Representation of each machine instruction.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Information about stack frame layout on the target.
virtual void resetCFIToInitialState(MachineBasicBlock &MBB) const
Emit CFI instructions that recreate the state of the unwind information upon fucntion entry.
virtual bool enableCFIFixup(MachineFunction &MF) const
Returns true if we may need to fix the unwind information for the function.
TargetInstrInfo - Interface to description of machine instruction set.
virtual const TargetFrameLowering * getFrameLowering() const
virtual const TargetInstrInfo * getInstrInfo() const
self_iterator getIterator()
This is an optimization pass for GlobalISel generic memory operations.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
auto reverse(ContainerTy &&C)
FunctionPass * createCFIFixup()
Creates CFI Fixup pass.