X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTarget%2FX86%2FX86PadShortFunction.cpp;h=0f425e28fa7d5dcbf80ed2a4d552440f07d38e08;hb=3c55c7bc30f513dd1544b3846e1204eb959f40e2;hp=76b318eca3c8e593a076e309efdf30d31b929570;hpb=42e8630239989fd40820975c361554546c1ccc2d;p=oota-llvm.git diff --git a/lib/Target/X86/X86PadShortFunction.cpp b/lib/Target/X86/X86PadShortFunction.cpp index 76b318eca3c..0f425e28fa7 100644 --- a/lib/Target/X86/X86PadShortFunction.cpp +++ b/lib/Target/X86/X86PadShortFunction.cpp @@ -17,6 +17,7 @@ #include "X86.h" #include "X86InstrInfo.h" +#include "X86Subtarget.h" #include "llvm/ADT/Statistic.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstrBuilder.h" @@ -50,7 +51,7 @@ namespace { struct PadShortFunc : public MachineFunctionPass { static char ID; PadShortFunc() : MachineFunctionPass(ID) - , Threshold(4), TM(0), TII(0) {} + , Threshold(4), STI(nullptr), TII(nullptr) {} bool runOnMachineFunction(MachineFunction &MF) override; @@ -78,7 +79,7 @@ namespace { // VisitedBBs - Cache of previously visited BBs. DenseMap VisitedBBs; - const TargetMachine *TM; + const X86Subtarget *STI; const TargetInstrInfo *TII; }; @@ -92,21 +93,20 @@ FunctionPass *llvm::createX86PadShortFunctions() { /// runOnMachineFunction - Loop over all of the basic blocks, inserting /// NOOP instructions before early exits. bool PadShortFunc::runOnMachineFunction(MachineFunction &MF) { - const AttributeSet &FnAttrs = MF.getFunction()->getAttributes(); - if (FnAttrs.hasAttribute(AttributeSet::FunctionIndex, - Attribute::OptimizeForSize) || - FnAttrs.hasAttribute(AttributeSet::FunctionIndex, - Attribute::MinSize)) { + if (MF.getFunction()->optForSize()) { return false; } - TM = &MF.getTarget(); - TII = TM->getInstrInfo(); + STI = &MF.getSubtarget(); + if (!STI->padShortFunctions()) + return false; + + TII = STI->getInstrInfo(); // Search through basic blocks and mark the ones that have early returns ReturnBBs.clear(); VisitedBBs.clear(); - findReturns(MF.begin()); + findReturns(&MF.front()); bool MadeChange = false; @@ -191,7 +191,7 @@ bool PadShortFunc::cyclesUntilReturn(MachineBasicBlock *MBB, return true; } - CyclesToEnd += TII->getInstrLatency(TM->getInstrItineraryData(), MI); + CyclesToEnd += TII->getInstrLatency(STI->getInstrItineraryData(), MI); } VisitedBBs[MBB] = VisitedBBInfo(false, CyclesToEnd);