1c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd//===-------- X86PadShortFunction.cpp - pad short functions -----------===// 2c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd// 3c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd// The LLVM Compiler Infrastructure 4c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd// 5c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd// This file is distributed under the University of Illinois Open Source 6c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd// License. See LICENSE.TXT for details. 7c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd// 8c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd//===----------------------------------------------------------------------===// 9c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd// 10c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd// This file defines the pass which will pad short functions to prevent 11c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd// a stall if a function returns before the return address is ready. This 12c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd// is needed for some Intel Atom processors. 13c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd// 14c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd//===----------------------------------------------------------------------===// 15c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd 16c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd#include <algorithm> 17c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd 18c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd#define DEBUG_TYPE "x86-pad-short-functions" 19c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd#include "X86.h" 20c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd#include "X86InstrInfo.h" 21c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd#include "llvm/ADT/Statistic.h" 22c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd#include "llvm/CodeGen/MachineFunctionPass.h" 23c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd#include "llvm/CodeGen/MachineInstrBuilder.h" 24c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd#include "llvm/CodeGen/MachineRegisterInfo.h" 25c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd#include "llvm/CodeGen/Passes.h" 26c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd#include "llvm/IR/Function.h" 27c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd#include "llvm/Support/Debug.h" 28c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd#include "llvm/Support/raw_ostream.h" 29c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd#include "llvm/Target/TargetInstrInfo.h" 30c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd 31c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurdusing namespace llvm; 32c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd 33c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston GurdSTATISTIC(NumBBsPadded, "Number of basic blocks padded"); 34c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd 35c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurdnamespace { 361452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd struct VisitedBBInfo { 371452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd // HasReturn - Whether the BB contains a return instruction 381452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd bool HasReturn; 391452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd 401452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd // Cycles - Number of cycles until return if HasReturn is true, otherwise 411452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd // number of cycles until end of the BB 421452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd unsigned int Cycles; 431452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd 441452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd VisitedBBInfo() : HasReturn(false), Cycles(0) {} 451452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd VisitedBBInfo(bool HasReturn, unsigned int Cycles) 461452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd : HasReturn(HasReturn), Cycles(Cycles) {} 471452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd }; 481452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd 49c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd struct PadShortFunc : public MachineFunctionPass { 50c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd static char ID; 51c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd PadShortFunc() : MachineFunctionPass(ID) 52c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd , Threshold(4), TM(0), TII(0) {} 53c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd 54c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd virtual bool runOnMachineFunction(MachineFunction &MF); 55c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd 56c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd virtual const char *getPassName() const { 57c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd return "X86 Atom pad short functions"; 58c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd } 59c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd 60c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd private: 61c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd void findReturns(MachineBasicBlock *MBB, 62c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd unsigned int Cycles = 0); 63c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd 64c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd bool cyclesUntilReturn(MachineBasicBlock *MBB, 651452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd unsigned int &Cycles); 66c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd 67c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd void addPadding(MachineBasicBlock *MBB, 68c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd MachineBasicBlock::iterator &MBBI, 69c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd unsigned int NOOPsToAdd); 70c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd 71c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd const unsigned int Threshold; 721452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd 731452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd // ReturnBBs - Maps basic blocks that return to the minimum number of 741452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd // cycles until the return, starting from the entry block. 75c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd DenseMap<MachineBasicBlock*, unsigned int> ReturnBBs; 76c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd 771452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd // VisitedBBs - Cache of previously visited BBs. 781452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd DenseMap<MachineBasicBlock*, VisitedBBInfo> VisitedBBs; 791452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd 80c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd const TargetMachine *TM; 81c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd const TargetInstrInfo *TII; 82c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd }; 83c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd 84c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd char PadShortFunc::ID = 0; 85c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd} 86c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd 87c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston GurdFunctionPass *llvm::createX86PadShortFunctions() { 88c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd return new PadShortFunc(); 89c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd} 90c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd 91c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd/// runOnMachineFunction - Loop over all of the basic blocks, inserting 92c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd/// NOOP instructions before early exits. 93c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurdbool PadShortFunc::runOnMachineFunction(MachineFunction &MF) { 941452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd const AttributeSet &FnAttrs = MF.getFunction()->getAttributes(); 951452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd if (FnAttrs.hasAttribute(AttributeSet::FunctionIndex, 961452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd Attribute::OptimizeForSize) || 971452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd FnAttrs.hasAttribute(AttributeSet::FunctionIndex, 981452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd Attribute::MinSize)) { 99c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd return false; 1001452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd } 101c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd 102c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd TM = &MF.getTarget(); 103c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd TII = TM->getInstrInfo(); 104c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd 105c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd // Search through basic blocks and mark the ones that have early returns 106c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd ReturnBBs.clear(); 1071452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd VisitedBBs.clear(); 108c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd findReturns(MF.begin()); 109c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd 110c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd bool MadeChange = false; 111c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd 112c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd MachineBasicBlock *MBB; 113c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd unsigned int Cycles = 0; 114c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd 115c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd // Pad the identified basic blocks with NOOPs 116c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd for (DenseMap<MachineBasicBlock*, unsigned int>::iterator I = ReturnBBs.begin(); 117c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd I != ReturnBBs.end(); ++I) { 118c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd MBB = I->first; 119c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd Cycles = I->second; 120c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd 121c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd if (Cycles < Threshold) { 1221452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd // BB ends in a return. Skip over any DBG_VALUE instructions 1231452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd // trailing the terminator. 1241452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd assert(MBB->size() > 0 && 1251452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd "Basic block should contain at least a RET but is empty"); 1261452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd MachineBasicBlock::iterator ReturnLoc = --MBB->end(); 1271452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd 1281452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd while (ReturnLoc->isDebugValue()) 1291452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd --ReturnLoc; 1301452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd assert(ReturnLoc->isReturn() && !ReturnLoc->isCall() && 1311452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd "Basic block does not end with RET"); 132c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd 133c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd addPadding(MBB, ReturnLoc, Threshold - Cycles); 134c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd NumBBsPadded++; 135c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd MadeChange = true; 136c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd } 137c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd } 138c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd 139c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd return MadeChange; 140c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd} 141c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd 142c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd/// findReturn - Starting at MBB, follow control flow and add all 143c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd/// basic blocks that contain a return to ReturnBBs. 144c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurdvoid PadShortFunc::findReturns(MachineBasicBlock *MBB, unsigned int Cycles) { 145c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd // If this BB has a return, note how many cycles it takes to get there. 146c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd bool hasReturn = cyclesUntilReturn(MBB, Cycles); 147c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd if (Cycles >= Threshold) 148c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd return; 149c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd 150c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd if (hasReturn) { 151c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd ReturnBBs[MBB] = std::max(ReturnBBs[MBB], Cycles); 152c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd return; 153c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd } 154c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd 155c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd // Follow branches in BB and look for returns 156c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd for (MachineBasicBlock::succ_iterator I = MBB->succ_begin(); 1571452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd I != MBB->succ_end(); ++I) { 1581452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd if (*I == MBB) 1591452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd continue; 160c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd findReturns(*I, Cycles); 161c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd } 162c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd} 163c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd 1641452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd/// cyclesUntilReturn - return true if the MBB has a return instruction, 1651452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd/// and return false otherwise. 166c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd/// Cycles will be incremented by the number of cycles taken to reach the 167c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd/// return or the end of the BB, whichever occurs first. 168c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurdbool PadShortFunc::cyclesUntilReturn(MachineBasicBlock *MBB, 1691452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd unsigned int &Cycles) { 1701452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd // Return cached result if BB was previously visited 1711452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd DenseMap<MachineBasicBlock*, VisitedBBInfo>::iterator it 1721452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd = VisitedBBs.find(MBB); 1731452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd if (it != VisitedBBs.end()) { 1741452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd VisitedBBInfo BBInfo = it->second; 1751452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd Cycles += BBInfo.Cycles; 1761452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd return BBInfo.HasReturn; 1771452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd } 1781452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd 1791452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd unsigned int CyclesToEnd = 0; 1801452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd 181c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd for (MachineBasicBlock::iterator MBBI = MBB->begin(); 182c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd MBBI != MBB->end(); ++MBBI) { 183c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd MachineInstr *MI = MBBI; 184c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd // Mark basic blocks with a return instruction. Calls to other 185c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd // functions do not count because the called function will be padded, 186c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd // if necessary. 187c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd if (MI->isReturn() && !MI->isCall()) { 1881452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd VisitedBBs[MBB] = VisitedBBInfo(true, CyclesToEnd); 1891452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd Cycles += CyclesToEnd; 190c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd return true; 191c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd } 192c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd 1931452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd CyclesToEnd += TII->getInstrLatency(TM->getInstrItineraryData(), MI); 194c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd } 195c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd 1961452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd VisitedBBs[MBB] = VisitedBBInfo(false, CyclesToEnd); 1971452d46e0bc5ca6bea77ca85abf9b694e3b6ab84Preston Gurd Cycles += CyclesToEnd; 198c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd return false; 199c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd} 200c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd 201c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd/// addPadding - Add the given number of NOOP instructions to the function 202c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd/// just prior to the return at MBBI 203c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurdvoid PadShortFunc::addPadding(MachineBasicBlock *MBB, 204c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd MachineBasicBlock::iterator &MBBI, 205c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd unsigned int NOOPsToAdd) { 206c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd DebugLoc DL = MBBI->getDebugLoc(); 207c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd 208c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd while (NOOPsToAdd-- > 0) { 209c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd BuildMI(*MBB, MBBI, DL, TII->get(X86::NOOP)); 210c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd BuildMI(*MBB, MBBI, DL, TII->get(X86::NOOP)); 211c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd } 212c7b902e7fe3498503efbfd98cabb1b1c67cadda6Preston Gurd} 213