[llvm] r190770 - Replace some unnecessary vector copies with references.
Benjamin Kramer
benny.kra at gmail.com
Sun Sep 15 15:16:42 PDT 2013
On Mon, Sep 16, 2013 at 12:12 AM, David Blaikie <dblaikie at gmail.com> wrote:
>
>
>
> On Sun, Sep 15, 2013 at 3:04 PM, Benjamin Kramer <benny.kra at googlemail.com>
> wrote:
>>
>> Author: d0k
>> Date: Sun Sep 15 17:04:42 2013
>> New Revision: 190770
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=190770&view=rev
>> Log:
>> Replace some unnecessary vector copies with references.
>
>
> would it be practical to change the return types of thees functions to
> ArrayRef to reduce the chance of accidental copying?
ArrayRef has a conversion operator for std::vector, won't that make
the copying even worse?
- Ben
>>
>>
>> Modified:
>> llvm/trunk/lib/CodeGen/MachineLICM.cpp
>> llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.cpp
>> llvm/trunk/lib/Target/Hexagon/HexagonHardwareLoops.cpp
>> llvm/trunk/lib/Target/SystemZ/SystemZConstantPoolValue.cpp
>> llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp
>> llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp
>>
>> Modified: llvm/trunk/lib/CodeGen/MachineLICM.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineLICM.cpp?rev=190770&r1=190769&r2=190770&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/CodeGen/MachineLICM.cpp (original)
>> +++ llvm/trunk/lib/CodeGen/MachineLICM.cpp Sun Sep 15 17:04:42 2013
>> @@ -502,7 +502,7 @@ void MachineLICM::HoistRegionPostRA() {
>>
>> // Walk the entire region, count number of defs for each register, and
>> // collect potential LICM candidates.
>> - const std::vector<MachineBasicBlock*> Blocks = CurLoop->getBlocks();
>> + const std::vector<MachineBasicBlock *> &Blocks = CurLoop->getBlocks();
>> for (unsigned i = 0, e = Blocks.size(); i != e; ++i) {
>> MachineBasicBlock *BB = Blocks[i];
>>
>> @@ -584,7 +584,7 @@ void MachineLICM::HoistRegionPostRA() {
>> /// AddToLiveIns - Add register 'Reg' to the livein sets of BBs in the
>> current
>> /// loop, and make sure it is not killed by any instructions in the loop.
>> void MachineLICM::AddToLiveIns(unsigned Reg) {
>> - const std::vector<MachineBasicBlock*> Blocks = CurLoop->getBlocks();
>> + const std::vector<MachineBasicBlock *> &Blocks = CurLoop->getBlocks();
>> for (unsigned i = 0, e = Blocks.size(); i != e; ++i) {
>> MachineBasicBlock *BB = Blocks[i];
>> if (!BB->isLiveIn(Reg))
>>
>> Modified: llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.cpp?rev=190770&r1=190769&r2=190770&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.cpp (original)
>> +++ llvm/trunk/lib/Target/ARM/ARMConstantPoolValue.cpp Sun Sep 15 17:04:42
>> 2013
>> @@ -164,7 +164,7 @@ const BlockAddress *ARMConstantPoolConst
>> int
>> ARMConstantPoolConstant::getExistingMachineCPValue(MachineConstantPool *CP,
>> unsigned
>> Alignment) {
>> unsigned AlignMask = Alignment - 1;
>> - const std::vector<MachineConstantPoolEntry> Constants =
>> CP->getConstants();
>> + const std::vector<MachineConstantPoolEntry> &Constants =
>> CP->getConstants();
>> for (unsigned i = 0, e = Constants.size(); i != e; ++i) {
>> if (Constants[i].isMachineConstantPoolEntry() &&
>> (Constants[i].getAlignment() & AlignMask) == 0) {
>> @@ -217,7 +217,7 @@ ARMConstantPoolSymbol::Create(LLVMContex
>> int ARMConstantPoolSymbol::getExistingMachineCPValue(MachineConstantPool
>> *CP,
>> unsigned Alignment)
>> {
>> unsigned AlignMask = Alignment - 1;
>> - const std::vector<MachineConstantPoolEntry> Constants =
>> CP->getConstants();
>> + const std::vector<MachineConstantPoolEntry> &Constants =
>> CP->getConstants();
>> for (unsigned i = 0, e = Constants.size(); i != e; ++i) {
>> if (Constants[i].isMachineConstantPoolEntry() &&
>> (Constants[i].getAlignment() & AlignMask) == 0) {
>> @@ -272,7 +272,7 @@ ARMConstantPoolMBB *ARMConstantPoolMBB::
>> int ARMConstantPoolMBB::getExistingMachineCPValue(MachineConstantPool
>> *CP,
>> unsigned Alignment) {
>> unsigned AlignMask = Alignment - 1;
>> - const std::vector<MachineConstantPoolEntry> Constants =
>> CP->getConstants();
>> + const std::vector<MachineConstantPoolEntry> &Constants =
>> CP->getConstants();
>> for (unsigned i = 0, e = Constants.size(); i != e; ++i) {
>> if (Constants[i].isMachineConstantPoolEntry() &&
>> (Constants[i].getAlignment() & AlignMask) == 0) {
>>
>> Modified: llvm/trunk/lib/Target/Hexagon/HexagonHardwareLoops.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonHardwareLoops.cpp?rev=190770&r1=190769&r2=190770&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/Target/Hexagon/HexagonHardwareLoops.cpp (original)
>> +++ llvm/trunk/lib/Target/Hexagon/HexagonHardwareLoops.cpp Sun Sep 15
>> 17:04:42 2013
>> @@ -871,7 +871,7 @@ bool HexagonHardwareLoops::isInvalidLoop
>> /// \brief - Return true if the loop contains an instruction that
>> inhibits
>> /// the use of the hardware loop function.
>> bool HexagonHardwareLoops::containsInvalidInstruction(MachineLoop *L)
>> const {
>> - const std::vector<MachineBasicBlock*> Blocks = L->getBlocks();
>> + const std::vector<MachineBasicBlock *> &Blocks = L->getBlocks();
>> for (unsigned i = 0, e = Blocks.size(); i != e; ++i) {
>> MachineBasicBlock *MBB = Blocks[i];
>> for (MachineBasicBlock::iterator
>>
>> Modified: llvm/trunk/lib/Target/SystemZ/SystemZConstantPoolValue.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZConstantPoolValue.cpp?rev=190770&r1=190769&r2=190770&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/Target/SystemZ/SystemZConstantPoolValue.cpp (original)
>> +++ llvm/trunk/lib/Target/SystemZ/SystemZConstantPoolValue.cpp Sun Sep 15
>> 17:04:42 2013
>> @@ -39,7 +39,7 @@ unsigned SystemZConstantPoolValue::getRe
>> int SystemZConstantPoolValue::
>> getExistingMachineCPValue(MachineConstantPool *CP, unsigned Alignment) {
>> unsigned AlignMask = Alignment - 1;
>> - const std::vector<MachineConstantPoolEntry> Constants =
>> CP->getConstants();
>> + const std::vector<MachineConstantPoolEntry> &Constants =
>> CP->getConstants();
>> for (unsigned I = 0, E = Constants.size(); I != E; ++I) {
>> if (Constants[I].isMachineConstantPoolEntry() &&
>> (Constants[I].getAlignment() & AlignMask) == 0) {
>>
>> Modified: llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp?rev=190770&r1=190769&r2=190770&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp (original)
>> +++ llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp Sun Sep 15 17:04:42
>> 2013
>> @@ -239,8 +239,6 @@ bool llvm::UnrollLoop(Loop *L, unsigned
>> DEBUG(dbgs() << "!\n");
>> }
>>
>> - std::vector<BasicBlock*> LoopBlocks = L->getBlocks();
>> -
>> bool ContinueOnTrue = L->contains(BI->getSuccessor(0));
>> BasicBlock *LoopExit = BI->getSuccessor(ContinueOnTrue);
>>
>>
>> Modified: llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp?rev=190770&r1=190769&r2=190770&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp (original)
>> +++ llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp Sun Sep 15 17:04:42
>> 2013
>> @@ -121,7 +121,7 @@ void RegisterInfoEmitter::runEnums(raw_o
>> OS << "}\n";
>> }
>>
>> - const std::vector<Record*> RegAltNameIndices =
>> Target.getRegAltNameIndices();
>> + const std::vector<Record*> &RegAltNameIndices =
>> Target.getRegAltNameIndices();
>> // If the only definition is the default NoRegAltName, we don't need to
>> // emit anything.
>> if (RegAltNameIndices.size() > 1) {
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
More information about the llvm-commits
mailing list