diff options
author | 2021-04-12 14:55:03 +0800 | |
---|---|---|
committer | 2021-04-12 14:55:03 +0800 | |
commit | d69c236e1d6b4705d3a0041f39bfe864638eb24e (patch) | |
tree | d922da0d56cf1d5d82b97bde71d883f858be0657 | |
parent | [libtooling][clang-tidy] Fix compiler warnings in testcase [NFC] (diff) | |
download | llvm-project-d69c236e1d6b4705d3a0041f39bfe864638eb24e.tar.gz llvm-project-d69c236e1d6b4705d3a0041f39bfe864638eb24e.tar.bz2 llvm-project-d69c236e1d6b4705d3a0041f39bfe864638eb24e.zip |
[NFC][Debug] Fix unnecessary deep-copy for vector to save compiling time
We saw some big compiling time impact after enabling the debug entry value
feature for X86 platform(D73534). Compiling time goes from 900s->1600s with
our testcase. It is caused by allocating/freeing the memory busily.
'using FwdRegWorklist = MapVector<unsigned, SmallVector<FwdRegParamInfo, 2>>;'
The value for this map is vector, and we miss the reference when access the
element. The same happens for `auto CalleesMap = MF->getCallSitesInfo();` which is a DenseMap.
Reviewed by: djtodoro, flychen50
Differential Revision: https://reviews.llvm.org/D100162
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index e99684957929..62dc3a6b62f3 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -717,7 +717,7 @@ static void interpretValues(const MachineInstr *CurMI, for (const MachineOperand &MO : MI.operands()) { if (MO.isReg() && MO.isDef() && Register::isPhysicalRegister(MO.getReg())) { - for (auto FwdReg : ForwardedRegWorklist) + for (auto &FwdReg : ForwardedRegWorklist) if (TRI.regsOverlap(FwdReg.first, MO.getReg())) Defs.insert(FwdReg.first); } @@ -766,7 +766,7 @@ static void interpretValues(const MachineInstr *CurMI, // Now that we are done handling this instruction, add items from the // temporary worklist to the real one. - for (auto New : TmpWorklistItems) + for (auto &New : TmpWorklistItems) addToFwdRegWorklist(ForwardedRegWorklist, New.first, EmptyExpr, New.second); TmpWorklistItems.clear(); } @@ -801,7 +801,7 @@ static bool interpretNextInstr(const MachineInstr *CurMI, static void collectCallSiteParameters(const MachineInstr *CallMI, ParamSet &Params) { const MachineFunction *MF = CallMI->getMF(); - auto CalleesMap = MF->getCallSitesInfo(); + const auto &CalleesMap = MF->getCallSitesInfo(); auto CallFwdRegsInfo = CalleesMap.find(CallMI); // There is no information for the call instruction. @@ -819,7 +819,7 @@ static void collectCallSiteParameters(const MachineInstr *CallMI, DIExpression::get(MF->getFunction().getContext(), {}); // Add all the forwarding registers into the ForwardedRegWorklist. - for (auto ArgReg : CallFwdRegsInfo->second) { + for (const auto &ArgReg : CallFwdRegsInfo->second) { bool InsertedReg = ForwardedRegWorklist.insert({ArgReg.Reg, {{ArgReg.Reg, EmptyExpr}}}) .second; @@ -867,7 +867,7 @@ static void collectCallSiteParameters(const MachineInstr *CallMI, // Create an expression where the register's entry value is used. DIExpression *EntryExpr = DIExpression::get( MF->getFunction().getContext(), {dwarf::DW_OP_LLVM_entry_value, 1}); - for (auto RegEntry : ForwardedRegWorklist) { + for (auto &RegEntry : ForwardedRegWorklist) { MachineLocation MLoc(RegEntry.first); finishCallSiteParams(MLoc, EntryExpr, RegEntry.second, Params); } |