31 SystemZLDCleanup() : MachineFunctionPass(ID), TII(nullptr), MF(nullptr) {}
33 bool runOnMachineFunction(MachineFunction &MF)
override;
34 void getAnalysisUsage(AnalysisUsage &AU)
const override;
38 MachineInstr *ReplaceTLSCall(MachineInstr *
I,
unsigned TLSBaseAddrReg);
39 MachineInstr *SetRegister(MachineInstr *
I,
unsigned *TLSBaseAddrReg);
41 const SystemZInstrInfo *TII;
45char SystemZLDCleanup::ID = 0;
50 "SystemZ Local Dynamic TLS Access Clean-up",
false,
false)
53 return new SystemZLDCleanup();
56void SystemZLDCleanup::getAnalysisUsage(
AnalysisUsage &AU)
const {
62bool SystemZLDCleanup::runOnMachineFunction(MachineFunction &
F) {
63 if (skipFunction(
F.getFunction()))
66 TII =
F.getSubtarget<SystemZSubtarget>().getInstrInfo();
69 SystemZMachineFunctionInfo* MFI =
F.
getInfo<SystemZMachineFunctionInfo>();
75 MachineDominatorTree *DT =
76 &getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree();
86 unsigned TLSBaseAddrReg) {
87 MachineBasicBlock *BB =
Node->getBlock();
92 switch (
I->getOpcode()) {
93 case SystemZ::TLS_LDCALL:
95 I = ReplaceTLSCall(&*
I, TLSBaseAddrReg);
97 I = SetRegister(&*
I, &TLSBaseAddrReg);
106 for (
auto &
N : *Node)
107 Changed |= VisitNode(
N, TLSBaseAddrReg);
114MachineInstr *SystemZLDCleanup::ReplaceTLSCall(MachineInstr *
I,
115 unsigned TLSBaseAddrReg) {
117 MachineInstr *
Copy =
BuildMI(*
I->getParent(),
I,
I->getDebugLoc(),
118 TII->get(TargetOpcode::COPY), SystemZ::R2D)
129MachineInstr *SystemZLDCleanup::SetRegister(MachineInstr *
I,
130 unsigned *TLSBaseAddrReg) {
132 MachineRegisterInfo &RegInfo = MF->
getRegInfo();
136 MachineInstr *
Next =
I->getNextNode();
138 TII->get(TargetOpcode::COPY), *TLSBaseAddrReg)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
const HexagonInstrInfo * TII
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
DomTreeNodeBase< NodeT > * getRootNode()
getRootNode - This returns the entry node for the CFG of the function.
FunctionPass class - This class is used to implement most global optimizations.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
LLVM_ABI void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
LLVM_ABI Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
unsigned getNumLocalDynamicTLSAccesses() const
NodeAddr< NodeBase * > Node
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.
FunctionPass * createSystemZLDCleanupPass(SystemZTargetMachine &TM)
DomTreeNodeBase< MachineBasicBlock > MachineDomTreeNode
FunctionAddr VTableAddr Next