diff options
author | Quentin Colombet <qcolombet@apple.com> | 2012-12-18 22:47:16 +0000 |
---|---|---|
committer | Quentin Colombet <qcolombet@apple.com> | 2012-12-18 22:47:16 +0000 |
commit | b519351b87204966d6548b198b88f2ab0f4d0b4b (patch) | |
tree | 7827db8d28c1736c13627222a6c624f7dc1e96d1 /lib/Target/ARM/Thumb2SizeReduction.cpp | |
parent | bd7b36e780f99b808f8e334e26f3dae1bc7e8175 (diff) | |
download | llvm-b519351b87204966d6548b198b88f2ab0f4d0b4b.tar.gz llvm-b519351b87204966d6548b198b88f2ab0f4d0b4b.tar.bz2 llvm-b519351b87204966d6548b198b88f2ab0f4d0b4b.tar.xz |
Disable ARM partial flag dependency optimization at -Oz
To not over constrain the scheduler for ARM in thumb mode, some optimizations for code size reduction, specific to ARM thumb, are blocked when they add a dependency (like write after read dependency).
Disables this check when code size is the priority, i.e., code is compiled with -Oz.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170462 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/ARM/Thumb2SizeReduction.cpp')
-rw-r--r-- | lib/Target/ARM/Thumb2SizeReduction.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/Target/ARM/Thumb2SizeReduction.cpp b/lib/Target/ARM/Thumb2SizeReduction.cpp index efc9bc3c23..04d5c373bd 100644 --- a/lib/Target/ARM/Thumb2SizeReduction.cpp +++ b/lib/Target/ARM/Thumb2SizeReduction.cpp @@ -22,6 +22,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Function.h" // To access Function attributes using namespace llvm; STATISTIC(NumNarrows, "Number of 32-bit instrs reduced to 16-bit ones"); @@ -182,11 +183,14 @@ namespace { /// ReduceMBB - Reduce width of instructions in the specified basic block. bool ReduceMBB(MachineBasicBlock &MBB); + + bool MinimizeSize; }; char Thumb2SizeReduce::ID = 0; } Thumb2SizeReduce::Thumb2SizeReduce() : MachineFunctionPass(ID) { + MinimizeSize = false; for (unsigned i = 0, e = array_lengthof(ReduceTable); i != e; ++i) { unsigned FromOpc = ReduceTable[i].WideOpc; if (!ReduceOpcodeMap.insert(std::make_pair(FromOpc, i)).second) @@ -221,8 +225,8 @@ static bool HasImplicitCPSRDef(const MCInstrDesc &MCID) { bool Thumb2SizeReduce::canAddPseudoFlagDep(MachineInstr *Def, MachineInstr *Use, bool FirstInSelfLoop) { - // FIXME: Disable check for -Oz (aka OptimizeForSizeHarder). - if (!STI->avoidCPSRPartialUpdate()) + // Disable the check for -Oz (aka OptimizeForSizeHarder). + if (MinimizeSize || !STI->avoidCPSRPartialUpdate()) return false; if (!Def) @@ -942,6 +946,10 @@ bool Thumb2SizeReduce::runOnMachineFunction(MachineFunction &MF) { TII = static_cast<const Thumb2InstrInfo*>(TM.getInstrInfo()); STI = &TM.getSubtarget<ARMSubtarget>(); + // When -Oz is set, the function carries MinSize attribute. + MinimizeSize = + MF.getFunction()->getFnAttributes().hasAttribute(Attributes::MinSize); + bool Modified = false; for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) Modified |= ReduceMBB(*I); |