diff options
author | Eric Christopher <echristo@gmail.com> | 2014-02-28 21:27:57 +0000 |
---|---|---|
committer | Eric Christopher <echristo@gmail.com> | 2014-02-28 21:27:57 +0000 |
commit | ede487cdb44ee9acb25369f0b0d8b6ab3556c869 (patch) | |
tree | a1866a0198b8741c32e30f0f2d76a243656a7454 /lib/IR | |
parent | 80883b6a27ef225e5761df5585147f39f130d248 (diff) | |
download | llvm-ede487cdb44ee9acb25369f0b0d8b6ab3556c869.tar.gz llvm-ede487cdb44ee9acb25369f0b0d8b6ab3556c869.tar.bz2 llvm-ede487cdb44ee9acb25369f0b0d8b6ab3556c869.tar.xz |
Fix a crasher where when we're attempting to replace a type
during the finalization for CGDebugInfo in clang we would RAUW
a type and it would result in a corrupted MDNode for an
imported declaration.
Testcase pending as reducing has been difficult.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202540 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR')
-rw-r--r-- | lib/IR/DIBuilder.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/IR/DIBuilder.cpp b/lib/IR/DIBuilder.cpp index 4bb75bdb0d..f5ccd5f2b6 100644 --- a/lib/IR/DIBuilder.cpp +++ b/lib/IR/DIBuilder.cpp @@ -69,7 +69,10 @@ void DIBuilder::finalize() { DIArray GVs = getOrCreateArray(AllGVs); DIType(TempGVs).replaceAllUsesWith(GVs); - DIArray IMs = getOrCreateArray(AllImportedModules); + SmallVector<Value *, 16> RetainValuesI; + for (unsigned I = 0, E = AllImportedModules.size(); I < E; I++) + RetainValuesI.push_back(AllImportedModules[I]); + DIArray IMs = getOrCreateArray(RetainValuesI); DIType(TempImportedModules).replaceAllUsesWith(IMs); } @@ -145,7 +148,7 @@ DICompileUnit DIBuilder::createCompileUnit(unsigned Lang, StringRef Filename, static DIImportedEntity createImportedModule(LLVMContext &C, DIScope Context, DIDescriptor NS, unsigned Line, StringRef Name, - SmallVectorImpl<Value *> &AllImportedModules) { + SmallVectorImpl<TrackingVH<MDNode>> &AllImportedModules) { const MDNode *R; if (Name.empty()) { Value *Elts[] = { @@ -167,7 +170,7 @@ createImportedModule(LLVMContext &C, DIScope Context, DIDescriptor NS, } DIImportedEntity M(R); assert(M.Verify() && "Imported module should be valid"); - AllImportedModules.push_back(M); + AllImportedModules.push_back(TrackingVH<MDNode>(M)); return M; } @@ -197,7 +200,7 @@ DIImportedEntity DIBuilder::createImportedDeclaration(DIScope Context, }; DIImportedEntity M(MDNode::get(VMContext, Elts)); assert(M.Verify() && "Imported module should be valid"); - AllImportedModules.push_back(M); + AllImportedModules.push_back(TrackingVH<MDNode>(M)); return M; } |