Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/Target/X86/X86RetpolineThunks.cpp
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | public: | ||||
StringRef getPassName() const override { return "X86 Retpoline Thunks"; } | StringRef getPassName() const override { return "X86 Retpoline Thunks"; } | ||||
bool doInitialization(Module &M) override; | bool doInitialization(Module &M) override; | ||||
bool runOnMachineFunction(MachineFunction &F) override; | bool runOnMachineFunction(MachineFunction &F) override; | ||||
void getAnalysisUsage(AnalysisUsage &AU) const override { | void getAnalysisUsage(AnalysisUsage &AU) const override { | ||||
MachineFunctionPass::getAnalysisUsage(AU); | MachineFunctionPass::getAnalysisUsage(AU); | ||||
AU.addRequired<MachineModuleInfo>(); | AU.addRequired<MachineModuleInfoWrapperPass>(); | ||||
AU.addPreserved<MachineModuleInfo>(); | AU.addPreserved<MachineModuleInfoWrapperPass>(); | ||||
} | } | ||||
private: | private: | ||||
MachineModuleInfo *MMI; | MachineModuleInfo *MMI; | ||||
const TargetMachine *TM; | const TargetMachine *TM; | ||||
bool Is64Bit; | bool Is64Bit; | ||||
const X86Subtarget *STI; | const X86Subtarget *STI; | ||||
const X86InstrInfo *TII; | const X86InstrInfo *TII; | ||||
Show All 21 Lines | |||||
bool X86RetpolineThunks::runOnMachineFunction(MachineFunction &MF) { | bool X86RetpolineThunks::runOnMachineFunction(MachineFunction &MF) { | ||||
LLVM_DEBUG(dbgs() << getPassName() << '\n'); | LLVM_DEBUG(dbgs() << getPassName() << '\n'); | ||||
TM = &MF.getTarget();; | TM = &MF.getTarget();; | ||||
STI = &MF.getSubtarget<X86Subtarget>(); | STI = &MF.getSubtarget<X86Subtarget>(); | ||||
TII = STI->getInstrInfo(); | TII = STI->getInstrInfo(); | ||||
Is64Bit = TM->getTargetTriple().getArch() == Triple::x86_64; | Is64Bit = TM->getTargetTriple().getArch() == Triple::x86_64; | ||||
MMI = &getAnalysis<MachineModuleInfo>(); | MMI = &getAnalysis<MachineModuleInfoWrapperPass>().getMMI(); | ||||
Module &M = const_cast<Module &>(*MMI->getModule()); | Module &M = const_cast<Module &>(*MMI->getModule()); | ||||
// If this function is not a thunk, check to see if we need to insert | // If this function is not a thunk, check to see if we need to insert | ||||
// a thunk. | // a thunk. | ||||
if (!MF.getName().startswith(ThunkNamePrefix)) { | if (!MF.getName().startswith(ThunkNamePrefix)) { | ||||
// If we've already inserted a thunk, nothing else to do. | // If we've already inserted a thunk, nothing else to do. | ||||
if (InsertedThunks) | if (InsertedThunks) | ||||
return false; | return false; | ||||
▲ Show 20 Lines • Show All 178 Lines • Show Last 20 Lines |