diff options
author | Reid Kleckner <rnk@google.com> | 2018-03-15 21:12:21 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2018-03-15 21:12:21 +0000 |
commit | 55baeefd54b1e89551545b01b82c5fbf041bb0ad (patch) | |
tree | 26879fd3b6b39a5814cbc0d577a711b7d7b3cc0b /llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | |
parent | a21d5f1e180e3b6831bf818bf723ad55e6a061e0 (diff) | |
download | bcm5719-llvm-55baeefd54b1e89551545b01b82c5fbf041bb0ad.tar.gz bcm5719-llvm-55baeefd54b1e89551545b01b82c5fbf041bb0ad.zip |
[codeview] Delete FunctionInfo copy ctor and move out of DenseMap
We were unnecessarily copying a bunch of these FunctionInfo objects
around when rehashing the DenseMap.
Furthermore, r327620 introduced pointers referring to objects owned by
FunctionInfo, and the default copy ctor did the wrong thing in this
case, leading to use-after-free when the DenseMap gets rehashed.
I will rebase r327620 on this next and recommit it.
llvm-svn: 327665
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp index 59b6c99f996..1ffc589d7f9 100644 --- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp @@ -470,7 +470,7 @@ void CodeViewDebug::endModule() { // Emit per-function debug information. for (auto &P : FnDebugInfo) if (!P.first->isDeclarationForLinker()) - emitDebugInfoForFunction(P.first, P.second); + emitDebugInfoForFunction(P.first, *P.second); // Emit global variable debug information. setCurrentSubprogram(nullptr); @@ -1162,8 +1162,9 @@ void CodeViewDebug::collectVariableInfo(const DISubprogram *SP) { void CodeViewDebug::beginFunctionImpl(const MachineFunction *MF) { const Function &GV = MF->getFunction(); - assert(FnDebugInfo.count(&GV) == false); - CurFn = &FnDebugInfo[&GV]; + auto Insertion = FnDebugInfo.insert({&GV, llvm::make_unique<FunctionInfo>()}); + assert(!Insertion.second && "emitting function twice"); + CurFn = Insertion.first->second.get(); CurFn->FuncId = NextFuncId++; CurFn->Begin = Asm->getFunctionBegin(); @@ -2365,7 +2366,7 @@ void CodeViewDebug::emitLocalVariable(const LocalVariable &Var) { void CodeViewDebug::endFunctionImpl(const MachineFunction *MF) { const Function &GV = MF->getFunction(); assert(FnDebugInfo.count(&GV)); - assert(CurFn == &FnDebugInfo[&GV]); + assert(CurFn == FnDebugInfo[&GV].get()); collectVariableInfo(GV.getSubprogram()); |