Use big obj copy in range for-loop will call copy constructor every time,
which can be avoided by use ref instead.
Details
- Reviewers
skan pengfei LuoYuanke - Commits
- rGfbb241c5523c: use ref to avoid copy in range for-loop
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
| llvm/include/llvm/MC/MCParser/MCAsmParser.h | ||
|---|---|---|
| 239 | Every element here is type MCPendingError defined in MCAsmPaser.h, It contains 1 SMLoc(has 1 internal pointer as member), 1 SmallString, 1 SMRange(composed of 2 SMLoc). struct MCPendingError {
SMLoc Loc;
SmallString<64> Msg;
SMRange Range;
};SmallVector<MCPendingError, 0> PendingErrors; This enumerated element has 4 pointers which is bigger than 64bit, I think it's better here to use ref. | |
| llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp | ||
| 1315 | The enumerated type is InstToEntryLocMap, every element is a pair of MachineInstr * and LocIndex(composed of 2 uint32_t. using InstToEntryLocMap = std::multimap<const MachineInstr *, LocIndex>; | |
| llvm/lib/CodeGen/MIRParser/MIRParser.cpp | ||
| 405 | YamlMF.CallSitesInfo is type CallSiteInfoMap, defined in MachineFunction.h line 452. struct ArgRegPair {
Register Reg;
uint16_t ArgNo;
ArgRegPair(Register R, unsigned Arg) : Reg(R), ArgNo(Arg) {
assert(Arg < (1 << 16) && "Arg out of range");
}
};
using CallSiteInfo = SmallVector<ArgRegPair, 1>;
...
using CallSiteInfoMap = DenseMap<const MachineInstr *, CallSiteInfo>;Every element here is of type CallSiteInfo which contains a vector. | |
| llvm/lib/ObjectYAML/MachOEmitter.cpp | ||
| 429 | The Opcode here is type MachOYAML::BindOpcode, defined in MachOYAML.h line 98. struct BindOpcode {
MachO::BindOpcode Opcode;
uint8_t Imm;
std::vector<yaml::Hex64> ULEBExtraData;
std::vector<int64_t> SLEBExtraData;
StringRef Symbol;
}; | |
| llvm/utils/TableGen/GlobalISel/GIMatchTree.cpp | ||
| 736 | It enumerated NewLeaves which is type GIMatchTreeBuilder::LeafVec and TraversedEdgesByNewLeaves. using LeafVec = std::vector<GIMatchTreeBuilderLeafInfo>; and contains to many elements. class GIMatchTreeBuilderLeafInfo {
protected:
GIMatchTreeBuilder &Builder;
GIMatchTreeLeafInfo Info;
const GIMatchDag &MatchDag;
/// The association between GIMatchDagInstr* and GIMatchTreeInstrInfo.
/// The primary reason for this members existence is to allow the use of
/// InstrIDToInfo.lookup() since that requires that the value is
/// default-constructible.
DenseMap<const GIMatchDagInstr *, GIMatchTreeInstrInfo> InstrNodeToInfo;
/// The instruction information for a given ID in the context of this
/// particular leaf.
DenseMap<unsigned, GIMatchTreeInstrInfo *> InstrIDToInfo;
......here I is a tuple composed of GIMatchTreeBuilderLeafInfo and BitVector, must be a big obj. | |
Every element here is type MCPendingError defined in MCAsmPaser.h, It contains 1 SMLoc(has 1 internal pointer as member), 1 SmallString, 1 SMRange(composed of 2 SMLoc).
struct MCPendingError { SMLoc Loc; SmallString<64> Msg; SMRange Range; };This enumerated element has 4 pointers which is bigger than 64bit, I think it's better here to use ref.