41#define AVOIDCALL_DESC "X86 avoid trailing call pass"
42#define AVOIDCALL_NAME "x86-avoid-trailing-call"
44#define DEBUG_TYPE AVOIDCALL_NAME
62char X86AvoidTrailingCallPass::ID = 0;
65 return new X86AvoidTrailingCallPass();
74 return MI.isCall() || (!
MI.isPseudo() && !
MI.isMetaInstruction());
79 return MI.isCall() && !
MI.isReturn();
82bool X86AvoidTrailingCallPass::runOnMachineFunction(
MachineFunction &MF) {
110 bool IsEmpty = LastRealInstr ==
MBB.
rend();
112 if (IsEmpty || IsCall) {
115 dbgs() <<
"inserting int3 after trailing call instruction:\n";
116 LastRealInstr->dump();
119 dbgs() <<
"inserting int3 in trailing empty MBB:\n";
127 MBBI = std::next(LastRealInstr.getReverse());
128 DL = LastRealInstr->getDebugLoc();
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
const HexagonInstrInfo * TII
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool isCallOrRealInstruction(MachineInstr &MI)
static bool isCallInstruction(const MachineInstr &MI)
FunctionPass class - This class is used to implement most global optimizations.
bool isEHFuncletEntry() const
Returns true if this is the entry block of an EH funclet.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Representation of each machine instruction.
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
StringRef - Represent a constant reference to a string, i.e.
bool isTargetWin64() const
const X86InstrInfo * getInstrInfo() const override
NodeTy * getNextNode()
Get the next node, or nullptr for the list tail.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
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.
auto reverse(ContainerTy &&C)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
FunctionPass * createX86AvoidTrailingCallPass()
Return a pass that inserts int3 at the end of the function if it ends with a CALL instruction.
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.