[llvm] d69c236 - [NFC][Debug] Fix unnecessary deep-copy for vector to save compiling time
Zhang Qing Shan via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 11 23:58:19 PDT 2021
Author: Zhang Qing Shan
Date: 2021-04-12T14:55:03+08:00
New Revision: d69c236e1d6b4705d3a0041f39bfe864638eb24e
URL: https://github.com/llvm/llvm-project/commit/d69c236e1d6b4705d3a0041f39bfe864638eb24e
DIFF: https://github.com/llvm/llvm-project/commit/d69c236e1d6b4705d3a0041f39bfe864638eb24e.diff
LOG: [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
Added:
Modified:
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index e99684957929f..62dc3a6b62f35 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);
}
More information about the llvm-commits
mailing list