[PATCH] D33704: [DIBuilder] Add a more fine-grained finalization method

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 1 13:43:08 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL304467: [DIBuilder] Add a more fine-grained finalization method (authored by kfischer).

Changed prior to commit:
  https://reviews.llvm.org/D33704?vs=100887&id=101095#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33704

Files:
  llvm/trunk/include/llvm/IR/DIBuilder.h
  llvm/trunk/lib/IR/DIBuilder.cpp


Index: llvm/trunk/include/llvm/IR/DIBuilder.h
===================================================================
--- llvm/trunk/include/llvm/IR/DIBuilder.h
+++ llvm/trunk/include/llvm/IR/DIBuilder.h
@@ -86,6 +86,10 @@
     /// Construct any deferred debug info descriptors.
     void finalize();
 
+    /// Finalize a specific subprogram - no new variables may be added to this
+    /// subprogram afterwards.
+    void finalizeSubprogram(DISubprogram *SP);
+
     /// A CompileUnit provides an anchor for all debugging
     /// information generated during this instance of compilation.
     /// \param Lang          Source programming language, eg. dwarf::DW_LANG_C99
Index: llvm/trunk/lib/IR/DIBuilder.cpp
===================================================================
--- llvm/trunk/lib/IR/DIBuilder.cpp
+++ llvm/trunk/lib/IR/DIBuilder.cpp
@@ -39,6 +39,21 @@
   UnresolvedNodes.emplace_back(N);
 }
 
+void DIBuilder::finalizeSubprogram(DISubprogram *SP) {
+  MDTuple *Temp = SP->getVariables().get();
+  if (!Temp || !Temp->isTemporary())
+    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());
+}
+
 void DIBuilder::finalize() {
   if (!CUNode) {
     assert(!AllowUnresolvedNodes &&
@@ -62,25 +77,11 @@
     CUNode->replaceRetainedTypes(MDTuple::get(VMContext, RetainValues));
 
   DISubprogramArray SPs = MDTuple::get(VMContext, AllSubprograms);
-  auto resolveVariables = [&](DISubprogram *SP) {
-    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);
+    finalizeSubprogram(SP);
   for (auto *N : RetainValues)
     if (auto *SP = dyn_cast<DISubprogram>(N))
-      resolveVariables(SP);
+      finalizeSubprogram(SP);
 
   if (!AllGVs.empty())
     CUNode->replaceGlobalVariables(MDTuple::get(VMContext, AllGVs));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33704.101095.patch
Type: text/x-patch
Size: 2358 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170601/09441404/attachment.bin>


More information about the llvm-commits mailing list