Go to the documentation of this file.
49 #define DEBUG_TYPE "x86-retpoline-thunks"
62 struct RetpolineThunkInserter :
ThunkInserter<RetpolineThunkInserter> {
66 return (STI.useRetpolineIndirectCalls() ||
67 STI.useRetpolineIndirectBranches()) &&
68 !STI.useRetpolineExternalThunk();
108 StringRef getPassName()
const override {
return "X86 Indirect Thunks"; }
110 bool doInitialization(
Module &
M)
override;
114 std::tuple<RetpolineThunkInserter, LVIThunkInserter> TIs;
117 template <
typename... ThunkInserterT>
119 std::tuple<ThunkInserterT...> &ThunkInserters) {
120 (void)std::initializer_list<int>{
121 (std::get<ThunkInserterT>(ThunkInserters).init(
M), 0)...};
123 template <
typename... ThunkInserterT>
125 std::tuple<ThunkInserterT...> &ThunkInserters) {
127 (void)std::initializer_list<int>{
128 Modified |= std::get<ThunkInserterT>(ThunkInserters).run(MMI, MF)...};
141 createThunkFunction(MMI,
Name);
149 "Should only have an r11 thunk on 64-bit targets");
215 const unsigned CallOpc = Is64Bit ? X86::CALL64pcrel32 : X86::CALLpcrel32;
216 const unsigned RetOpc = Is64Bit ? X86::RET64 : X86::RET32;
218 Entry->addLiveIn(ThunkReg);
224 Entry->addSuccessor(CaptureSpec);
245 const unsigned MovOpc = Is64Bit ? X86::MOV64mr : X86::MOV32mr;
256 return new X86IndirectThunks();
261 bool X86IndirectThunks::doInitialization(
Module &M) {
268 auto &MMI = getAnalysis<MachineModuleInfoWrapperPass>().getMMI();
269 return runTIs(MMI, MF, TIs);
This is an optimization pass for GlobalISel generic memory operations.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
MCContext & getContext() const
static const char R11RetpolineName[]
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
FunctionPass * createX86IndirectThunksPass()
This pass creates the thunks for the retpoline feature.
static const MachineInstrBuilder & addRegOffset(const MachineInstrBuilder &MIB, unsigned Reg, bool isKill, int Offset)
addRegOffset - This function is used to add a memory reference of the form [Reg + Offset],...
static const char EDXRetpolineName[]
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
const MachineBasicBlock & front() const
TargetInstrInfo - Interface to description of machine instruction set.
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
static const char EAXRetpolineName[]
const LLVMTargetMachine & getTarget() const
const HexagonInstrInfo * TII
This class contains meta information specific to a module.
void setPreInstrSymbol(MachineFunction &MF, MCSymbol *Symbol)
Set a symbol that will be emitted just prior to the instruction itself.
ArchType getArch() const
Get the parsed architecture type of this triple.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
void setAlignment(Align A)
Set alignment of the basic block.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
void push_back(MachineBasicBlock *MBB)
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=nullptr)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
static const char EDIRetpolineName[]
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void setHasAddressTaken()
Set this block to reflect that it potentially is the target of an indirect branch.
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
A Module instance is used to store all the information related to an LLVM module.
StringRef - Represent a constant reference to a string, i.e.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
Wrapper class representing virtual and physical registers.
void addLiveIn(MCRegister PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
static const char R11LVIThunkName[]
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
static const char RetpolineNamePrefix[]
const MachineInstrBuilder & addSym(MCSymbol *Sym, unsigned char TargetFlags=0) const
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
static const char ECXRetpolineName[]
const Triple & getTargetTriple() const
FunctionPass class - This class is used to implement most global optimizations.
static const char LVIThunkNamePrefix[]