21 #define DEBUG_TYPE "x86-avoid-trailing-call" 35 return "X86 avoid trailing call pass";
45 return new X86AvoidTrailingCallPass();
60 bool X86AvoidTrailingCallPass::runOnMachineFunction(
MachineFunction &MF) {
80 make_range(MBB.getReverseIterator(), MF.rend())) {
82 if (LastRealInstr != RMBB.rend())
87 if (LastRealInstr == MF.begin()->rend())
95 dbgs() <<
"inserting int3 after trailing call instruction:\n";
96 LastRealInstr->dump();
101 BuildMI(*LastRealInstr->getParent(), MBBI, LastRealInstr->getDebugLoc(),
bool isCall(QueryType Type=AnyInBundle) const
NodeTy * getNextNode()
Get the next node, or nullptr for the list tail.
This class represents lattice values for constants.
const X86InstrInfo * getInstrInfo() const override
bool isMetaInstruction() const
Return true if this instruction doesn't produce any output in the form of executable instructions...
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const HexagonInstrInfo * TII
MachineBasicBlock iterator that automatically skips over MIs that are inside bundles (i...
static bool isRealInstruction(MachineInstr &MI)
auto reverse(ContainerTy &&C, typename std::enable_if< has_rbegin< ContainerTy >::value >::type *=nullptr) -> decltype(make_range(C.rbegin(), C.rend()))
reverse_iterator getReverse() const
Get a reverse iterator to the same node.
bool isReturn(QueryType Type=AnyInBundle) const
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
bool isPseudo(QueryType Type=IgnoreBundle) const
Return true if this is a pseudo instruction that doesn't correspond to a real machine instruction...
static bool isCallInstruction(const MachineInstr &MI)
FunctionPass class - This class is used to implement most global optimizations.
auto find_if(R &&Range, UnaryPredicate P) -> decltype(adl_begin(Range))
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly...
bool isTargetWin64() const
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Representation of each machine instruction.
bool isEHFuncletEntry() const
Returns true if this is the entry block of an EH funclet.
FunctionPass * createX86AvoidTrailingCallPass()
Return a pass that inserts int3 at the end of the function if it ends with a CALL instruction...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringRef - Represent a constant reference to a string, i.e.