<div dir="rtl"><div dir="ltr"><span style="font-size:12.8000001907349px">>void replaceEnumTypes(</span><span style="font-size:12.8000001907349px">DISubprogramArray N) {</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">>void </span><span class="" style="font-size:12.8000001907349px;background-color:rgb(255,255,255)">replaceRetainedTypes</span><span style="font-size:12.8000001907349px">(</span><span style="font-size:12.8000001907349px">DISubprogramArray N) {</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">>void replaceImportedEntities(</span><span style="font-size:12.8000001907349px">DIGlobalVariableArray N) {</span><br style="font-size:12.8000001907349px"><br></div><div dir="ltr"><span style="font-size:12.8000001907349px">Shouldn't replaceEnumTypes, </span><span style="font-size:12.8000001907349px">replaceRetainedTypes and </span><span style="font-size:12.8000001907349px">replaceImportedEntities </span><span style="font-size:12.8000001907349px">accept DICompositeTypeArray, DITypeArray and DIImportedEntityArray respectively?</span></div><div dir="ltr"><span style="font-size:12.8000001907349px"><br></span></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div dir="ltr">2015-07-03 1:32 GMT+03:00 Adrian Prantl <span dir="ltr"><<a href="mailto:aprantl@apple.com" target="_blank">aprantl@apple.com</a>></span>:</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: adrian<br>
Date: Thu Jul 2 17:32:52 2015<br>
New Revision: 241308<br>
<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D241308-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=HiH98LJsNAdOwjD3f7DwAwKdmlb-N9VWf2eGStkbUDk&s=t__bI2rYLgWb6L3yovCfcrfdSbBdvdGkSwlYZeZfN9M&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=241308&view=rev</a><br>
Log:<br>
DIBuilder: Now that DICompileUnit is distinct, stop using temporary nodes<br>
for the arrays.<br>
<br>
Modified:<br>
llvm/trunk/include/llvm/IR/DIBuilder.h<br>
llvm/trunk/include/llvm/IR/DebugInfoMetadata.h<br>
llvm/trunk/lib/IR/DIBuilder.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/IR/DIBuilder.h<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_include_llvm_IR_DIBuilder.h-3Frev-3D241308-26r1-3D241307-26r2-3D241308-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=HiH98LJsNAdOwjD3f7DwAwKdmlb-N9VWf2eGStkbUDk&s=m_x7OSBL1q4JRlXBK8x1XWiFKlxEVmeTuzO3003c84Y&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DIBuilder.h?rev=241308&r1=241307&r2=241308&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/IR/DIBuilder.h (original)<br>
+++ llvm/trunk/include/llvm/IR/DIBuilder.h Thu Jul 2 17:32:52 2015<br>
@@ -36,14 +36,9 @@ namespace llvm {<br>
Module &M;<br>
LLVMContext &VMContext;<br>
<br>
- TempMDTuple TempEnumTypes;<br>
- TempMDTuple TempRetainTypes;<br>
- TempMDTuple TempSubprograms;<br>
- TempMDTuple TempGVs;<br>
- TempMDTuple TempImportedModules;<br>
-<br>
- Function *DeclareFn; // llvm.dbg.declare<br>
- Function *ValueFn; // llvm.dbg.value<br>
+ DICompileUnit *CUNode; ///< The one compile unit created by this DIBuiler.<br>
+ Function *DeclareFn; ///< llvm.dbg.declare<br>
+ Function *ValueFn; ///< llvm.dbg.value<br>
<br>
SmallVector<Metadata *, 4> AllEnumTypes;<br>
/// Track the RetainTypes, since they can be updated later on.<br>
<br>
Modified: llvm/trunk/include/llvm/IR/DebugInfoMetadata.h<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_include_llvm_IR_DebugInfoMetadata.h-3Frev-3D241308-26r1-3D241307-26r2-3D241308-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=HiH98LJsNAdOwjD3f7DwAwKdmlb-N9VWf2eGStkbUDk&s=8xLbO9sPAEmSR98cK5hXb4hepv_Nikp5EqgMogsRfW4&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfoMetadata.h?rev=241308&r1=241307&r2=241308&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/IR/DebugInfoMetadata.h (original)<br>
+++ llvm/trunk/include/llvm/IR/DebugInfoMetadata.h Thu Jul 2 17:32:52 2015<br>
@@ -1085,12 +1085,21 @@ public:<br>
/// deleted on a uniquing collision. In practice, uniquing collisions on \a<br>
/// DICompileUnit should be fairly rare.<br>
/// @{<br>
+ void replaceEnumTypes(DISubprogramArray N) {<br>
+ replaceOperandWith(4, N.get());<br>
+ }<br>
+ void replaceRetainedTypes(DISubprogramArray N) {<br>
+ replaceOperandWith(5, N.get());<br>
+ }<br>
void replaceSubprograms(DISubprogramArray N) {<br>
replaceOperandWith(6, N.get());<br>
}<br>
void replaceGlobalVariables(DIGlobalVariableArray N) {<br>
replaceOperandWith(7, N.get());<br>
}<br>
+ void replaceImportedEntities(DIGlobalVariableArray N) {<br>
+ replaceOperandWith(8, N.get());<br>
+ }<br>
/// @}<br>
<br>
static bool classof(const Metadata *MD) {<br>
<br>
Modified: llvm/trunk/lib/IR/DIBuilder.cpp<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_IR_DIBuilder.cpp-3Frev-3D241308-26r1-3D241307-26r2-3D241308-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=HiH98LJsNAdOwjD3f7DwAwKdmlb-N9VWf2eGStkbUDk&s=QrB6Glf9bFjJCWprBHhFNsoIP5IrnUvWnWVgge7vT1I&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DIBuilder.cpp?rev=241308&r1=241307&r2=241308&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/IR/DIBuilder.cpp (original)<br>
+++ llvm/trunk/lib/IR/DIBuilder.cpp Thu Jul 2 17:32:52 2015<br>
@@ -58,8 +58,7 @@ public:<br>
}<br>
<br>
DIBuilder::DIBuilder(Module &m, bool AllowUnresolvedNodes)<br>
- : M(m), VMContext(M.getContext()), TempEnumTypes(nullptr),<br>
- TempRetainTypes(nullptr), TempSubprograms(nullptr), TempGVs(nullptr),<br>
+ : M(m), VMContext(M.getContext()), CUNode(nullptr),<br>
DeclareFn(nullptr), ValueFn(nullptr),<br>
AllowUnresolvedNodes(AllowUnresolvedNodes) {}<br>
<br>
@@ -74,35 +73,37 @@ void DIBuilder::trackIfUnresolved(MDNode<br>
}<br>
<br>
void DIBuilder::finalize() {<br>
- TempEnumTypes->replaceAllUsesWith(MDTuple::get(VMContext, AllEnumTypes));<br>
+ if (CUNode) {<br>
+ CUNode->replaceEnumTypes(MDTuple::get(VMContext, AllEnumTypes));<br>
<br>
- SmallVector<Metadata *, 16> RetainValues;<br>
- // Declarations and definitions of the same type may be retained. Some<br>
- // clients RAUW these pairs, leaving duplicates in the retained types<br>
- // list. Use a set to remove the duplicates while we transform the<br>
- // TrackingVHs back into Values.<br>
- SmallPtrSet<Metadata *, 16> RetainSet;<br>
- for (unsigned I = 0, E = AllRetainTypes.size(); I < E; I++)<br>
- if (RetainSet.insert(AllRetainTypes[I]).second)<br>
- RetainValues.push_back(AllRetainTypes[I]);<br>
- TempRetainTypes->replaceAllUsesWith(MDTuple::get(VMContext, RetainValues));<br>
-<br>
- DISubprogramArray SPs = MDTuple::get(VMContext, AllSubprograms);<br>
- TempSubprograms->replaceAllUsesWith(SPs.get());<br>
- for (auto *SP : SPs) {<br>
- if (MDTuple *Temp = SP->getVariables().get()) {<br>
- const auto &PV = PreservedVariables.lookup(SP);<br>
- SmallVector<Metadata *, 4> Variables(PV.begin(), PV.end());<br>
- DINodeArray AV = getOrCreateArray(Variables);<br>
- TempMDTuple(Temp)->replaceAllUsesWith(AV.get());<br>
+ SmallVector<Metadata *, 16> RetainValues;<br>
+ // Declarations and definitions of the same type may be retained. Some<br>
+ // clients RAUW these pairs, leaving duplicates in the retained types<br>
+ // list. Use a set to remove the duplicates while we transform the<br>
+ // TrackingVHs back into Values.<br>
+ SmallPtrSet<Metadata *, 16> RetainSet;<br>
+ for (unsigned I = 0, E = AllRetainTypes.size(); I < E; I++)<br>
+ if (RetainSet.insert(AllRetainTypes[I]).second)<br>
+ RetainValues.push_back(AllRetainTypes[I]);<br>
+ CUNode->replaceRetainedTypes(MDTuple::get(VMContext, RetainValues));<br>
+<br>
+ DISubprogramArray SPs = MDTuple::get(VMContext, AllSubprograms);<br>
+ CUNode->replaceSubprograms(SPs.get());<br>
+ for (auto *SP : SPs) {<br>
+ if (MDTuple *Temp = SP->getVariables().get()) {<br>
+ const auto &PV = PreservedVariables.lookup(SP);<br>
+ SmallVector<Metadata *, 4> Variables(PV.begin(), PV.end());<br>
+ DINodeArray AV = getOrCreateArray(Variables);<br>
+ TempMDTuple(Temp)->replaceAllUsesWith(AV.get());<br>
+ }<br>
}<br>
- }<br>
<br>
- TempGVs->replaceAllUsesWith(MDTuple::get(VMContext, AllGVs));<br>
+ CUNode->replaceGlobalVariables(MDTuple::get(VMContext, AllGVs));<br>
<br>
- TempImportedModules->replaceAllUsesWith(MDTuple::get(<br>
- VMContext, SmallVector<Metadata *, 16>(AllImportedModules.begin(),<br>
- AllImportedModules.end())));<br>
+ CUNode->replaceImportedEntities(MDTuple::get(<br>
+ VMContext, SmallVector<Metadata *, 16>(AllImportedModules.begin(),<br>
+ AllImportedModules.end())));<br>
+ }<br>
<br>
// Now that all temp nodes have been replaced or deleted, resolve remaining<br>
// cycles.<br>
@@ -133,19 +134,11 @@ DICompileUnit *DIBuilder::createCompileU<br>
assert(!Filename.empty() &&<br>
"Unable to create compile unit without filename");<br>
<br>
- // TODO: Once we make DICompileUnit distinct, stop using temporaries here<br>
- // (just start with operands assigned to nullptr).<br>
- TempEnumTypes = MDTuple::getTemporary(VMContext, None);<br>
- TempRetainTypes = MDTuple::getTemporary(VMContext, None);<br>
- TempSubprograms = MDTuple::getTemporary(VMContext, None);<br>
- TempGVs = MDTuple::getTemporary(VMContext, None);<br>
- TempImportedModules = MDTuple::getTemporary(VMContext, None);<br>
-<br>
- DICompileUnit *CUNode = DICompileUnit::getDistinct(<br>
+ assert(!CUNode && "Can only make one compile unit per DIBuilder instance");<br>
+ CUNode = DICompileUnit::getDistinct(<br>
VMContext, Lang, DIFile::get(VMContext, Filename, Directory), Producer,<br>
- isOptimized, Flags, RunTimeVer, SplitName, Kind, TempEnumTypes.get(),<br>
- TempRetainTypes.get(), TempSubprograms.get(), TempGVs.get(),<br>
- TempImportedModules.get(), DWOId);<br>
+ isOptimized, Flags, RunTimeVer, SplitName, Kind, nullptr,<br>
+ nullptr, nullptr, nullptr, nullptr, DWOId);<br>
<br>
// Create a named metadata so that it is easier to find cu in a module.<br>
// Note that we only generate this when the caller wants to actually<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>