17 #define DEBUG_TYPE "x86-vzeroupper"
30 STATISTIC(NumVZU,
"Number of vzeroupper instructions inserted");
41 virtual const char *getPassName()
const {
return "X86 vzeroupper inserter";}
86 static unsigned computeState(
unsigned PrevState,
unsigned CurState) {
87 if (PrevState == ST_INIT)
90 if (PrevState == ST_DIRTY || CurState == ST_DIRTY)
93 if (PrevState == ST_CLEAN && CurState == ST_CLEAN)
104 return new VZeroUpperInserter();
108 return (Reg >= X86::YMM0 && Reg <= X86::YMM31);
112 return (Reg >= X86::ZMM0 && Reg <= X86::ZMM31);
125 for (
unsigned reg = X86::YMM0; reg < X86::YMM31; ++reg) {
129 for (
unsigned reg = X86::ZMM0; reg < X86::ZMM31; ++reg) {
156 bool EverMadeChange =
false;
161 bool YMMUsed =
false;
171 return EverMadeChange;
176 assert(BBState.empty());
184 bool MadeChange =
false;
188 MadeChange |= processBasicBlock(MF, *
I);
191 if (!MadeChange)
break;
192 EverMadeChange =
true;
197 return EverMadeChange;
204 bool Changed =
false;
212 unsigned EntryState = ST_INIT;
214 PE = BB.
pred_end(); PI != PE; ++PI) {
215 EntryState = computeState(EntryState, BBState[(*PI)->getNumber()]);
216 if (EntryState == ST_DIRTY)
223 if (&BB == MF.
begin()) {
224 EntryState = ST_CLEAN;
226 EntryState = ST_DIRTY;
230 unsigned CurState = EntryState;
231 bool BBHasCall =
false;
248 if (!isControlFlow && CurState == ST_DIRTY)
273 if (CurState == ST_DIRTY) {
277 if (EntryState != ST_UNKNOWN) {
290 <<
", current state: " << CurState <<
'\n');
299 if (EntryState != ST_UNKNOWN || (!BBHasCall && CurState != ST_UNKNOWN))
300 BBSolved[BBNum] =
true;
302 if (CurState != BBState[BBNum])
305 BBState[BBNum] = CurState;
livein_iterator livein_end() const
FunctionPass * createX86IssueVZeroUpperPass()
const MCPhysReg * iterator
unsigned getNumBlockIDs() const
const HexagonInstrInfo * TII
bool isReg() const
isReg - Tests if this is a MO_Register operand.
static bool isZmmReg(unsigned Reg)
ID
LLVM Calling Convention Representation.
unsigned getNumOperands() const
static bool hasYmmReg(MachineInstr *MI)
bundle_iterator< MachineInstr, instr_iterator > iterator
static bool checkFnHasLiveInYmm(MachineRegisterInfo &MRI)
bool isReturn(QueryType Type=AnyInBundle) const
STATISTIC(NumVZU,"Number of vzeroupper instructions inserted")
const MachineOperand & getOperand(unsigned i) const
bool getFlag(MIFlag Flag) const
getFlag - Return whether an MI flag is set.
MachineInstrBuilder BuildMI(MachineFunction &MF, DebugLoc DL, const MCInstrDesc &MCID)
pred_iterator pred_begin()
std::vector< MachineBasicBlock * >::const_iterator const_pred_iterator
bool isRegMask() const
isRegMask - Tests if this is a MO_RegisterMask operand.
virtual const TargetInstrInfo * getInstrInfo() const
livein_iterator livein_begin() const
static bool isYmmReg(unsigned Reg)
raw_ostream & dbgs()
dbgs - Return a circular-buffered debug stream.
static bool clobbersPhysReg(const uint32_t *RegMask, unsigned PhysReg)
MachineRegisterInfo & getRegInfo()
bool isCall(QueryType Type=AnyInBundle) const
const TargetMachine & getTarget() const
std::vector< std::pair< unsigned, unsigned > >::const_iterator livein_iterator
unsigned getReg() const
getReg - Returns the register number.
static bool clobbersAllYmmRegs(const MachineOperand &MO)
BasicBlockListType::iterator iterator
const MCRegisterInfo & MRI
bool reg_nodbg_empty(unsigned RegNo) const