IR: Stop copying vectors of TrackingMDRef in DIBuilder

No real functionality change here, just avoiding an unnecessary copy of
std::vector<TrackingMDRef> for every subprogram with variables.

llvm-svn: 266907
This commit is contained in:
Duncan P. N. Exon Smith 2016-04-20 20:03:59 +00:00
parent a83bfeac9d
commit a2495d9c5a
1 changed files with 12 additions and 6 deletions

View File

@ -97,12 +97,18 @@ void DIBuilder::finalize() {
DISubprogramArray SPs = MDTuple::get(VMContext, AllSubprograms);
auto resolveVariables = [&](DISubprogram *SP) {
if (MDTuple *Temp = SP->getVariables().get()) {
const auto &PV = PreservedVariables.lookup(SP);
SmallVector<Metadata *, 4> Variables(PV.begin(), PV.end());
DINodeArray AV = getOrCreateArray(Variables);
TempMDTuple(Temp)->replaceAllUsesWith(AV.get());
}
MDTuple *Temp = SP->getVariables().get();
if (!Temp)
return;
SmallVector<Metadata *, 4> Variables;
auto PV = PreservedVariables.find(SP);
if (PV != PreservedVariables.end())
Variables.append(PV->second.begin(), PV->second.end());
DINodeArray AV = getOrCreateArray(Variables);
TempMDTuple(Temp)->replaceAllUsesWith(AV.get());
};
for (auto *SP : SPs)
resolveVariables(SP);