[PATCH] D33704: [DIBuilder] Add a more fine-grained finalization method
Keno Fischer via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 31 10:51:11 PDT 2017
loladiro updated this revision to Diff 100887.
loladiro added a comment.
finalizeSP -> finalizeSubprogram
I don't think there's really a natural place in DIBuilder to do this, but
I suspect that most frontends would have one.
https://reviews.llvm.org/D33704
Files:
include/llvm/IR/DIBuilder.h
lib/IR/DIBuilder.cpp
Index: lib/IR/DIBuilder.cpp
===================================================================
--- lib/IR/DIBuilder.cpp
+++ 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));
Index: include/llvm/IR/DIBuilder.h
===================================================================
--- include/llvm/IR/DIBuilder.h
+++ 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33704.100887.patch
Type: text/x-patch
Size: 2292 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170531/b2d6d7ae/attachment.bin>
More information about the llvm-commits
mailing list