44#define PASS_KEY "x86-return-thunks"
45#define DEBUG_TYPE PASS_KEY
51 StringRef getPassName()
const override {
return "X86 Return Thunks"; }
56char X86ReturnThunks::ID = 0;
66 StringRef ThunkName =
"__x86_return_thunk";
72 const unsigned RetOpc = Is64Bit ? X86::RET64 : X86::RET32;
75 for (MachineBasicBlock &
MBB : MF)
77 if (
Term.getOpcode() == RetOpc)
81 MF.getFunction().getParent()->getModuleFlag(
"indirect_branch_cs_prefix");
82 const MCInstrDesc &CS =
ST.getInstrInfo()->get(X86::CS_PREFIX);
83 const MCInstrDesc &JMP =
ST.getInstrInfo()->get(X86::TAILJMPd);
85 for (MachineInstr *Ret : Rets) {
90 Ret->eraseFromParent();
100 return new X86ReturnThunks();
Module.h This file contains the declarations for the Module class.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This file defines the SmallVector class.
FunctionPass class - This class is used to implement most global optimizations.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
iterator_range< iterator > terminators()
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Function & getFunction()
Return the LLVM function that this machine code represents.
const MachineInstrBuilder & addExternalSymbol(const char *FnName, unsigned TargetFlags=0) const
void push_back(const T &Elt)
StringRef - Represent a constant reference to a string, i.e.
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
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.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
FunctionPass * createX86ReturnThunksPass()
This pass replaces ret instructions with jmp's to __x86_return thunk.