[llvm] r202540 - Fix a crasher where when we're attempting to replace a type
Eric Christopher
echristo at gmail.com
Fri Feb 28 13:27:57 PST 2014
Author: echristo
Date: Fri Feb 28 15:27:57 2014
New Revision: 202540
URL: http://llvm.org/viewvc/llvm-project?rev=202540&view=rev
Log:
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.
Modified:
llvm/trunk/include/llvm/DIBuilder.h
llvm/trunk/lib/IR/DIBuilder.cpp
Modified: llvm/trunk/include/llvm/DIBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DIBuilder.h?rev=202540&r1=202539&r2=202540&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DIBuilder.h (original)
+++ llvm/trunk/include/llvm/DIBuilder.h Fri Feb 28 15:27:57 2014
@@ -72,7 +72,7 @@ namespace llvm {
SmallVector<TrackingVH<MDNode>, 4> AllRetainTypes;
SmallVector<Value *, 4> AllSubprograms;
SmallVector<Value *, 4> AllGVs;
- SmallVector<Value *, 4> AllImportedModules;
+ SmallVector<TrackingVH<MDNode>, 4> AllImportedModules;
// Private use for multiple types of template parameters.
DITemplateValueParameter
Modified: llvm/trunk/lib/IR/DIBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DIBuilder.cpp?rev=202540&r1=202539&r2=202540&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DIBuilder.cpp (original)
+++ llvm/trunk/lib/IR/DIBuilder.cpp Fri Feb 28 15:27:57 2014
@@ -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::createCompileUn
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, DIS
}
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::createImport
};
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;
}
More information about the llvm-commits
mailing list