[PATCH] D33705: [CGVTables] Finalize SP before attempting to clone it
Keno Fischer via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue May 30 17:30:37 PDT 2017
loladiro created this revision.
LLVM commit https://reviews.llvm.org/D33655 was reverted, because it exposed an assertion failure,
in `GenerateVarArgsThunk`. That function attempts to clone a function
before clang is entirely done generating the debug info for the current
compliation unit. That is not a valid use of the API, because it expects
that there are no temporary MD nodes in the nodes that it needs to clone.
However, until now, this did not cause any problems (though could have
caused assertions in the backend due to mismatched debug info metadata).
Attempt to rectify this by finalizing the SP before attempting to clone it.
The requisite LLVM API is being introduced in https://reviews.llvm.org/D33704.
https://reviews.llvm.org/D33705
Files:
lib/CodeGen/CGDebugInfo.h
lib/CodeGen/CGVTables.cpp
Index: lib/CodeGen/CGVTables.cpp
===================================================================
--- lib/CodeGen/CGVTables.cpp
+++ lib/CodeGen/CGVTables.cpp
@@ -152,6 +152,12 @@
llvm::Value *Callee = CGM.GetAddrOfFunction(GD, Ty, /*ForVTable=*/true);
llvm::Function *BaseFn = cast<llvm::Function>(Callee);
+ // We may not clone a subprogram that contains temporary metadata, so finalize
+ // it now - we will not be modifying it.
+ if (CGDebugInfo *DI = CGM.getModuleDebugInfo())
+ if (llvm::DISubprogram *SP = BaseFn->getSubprogram())
+ DI->finalizeSP(SP);
+
// Clone to thunk.
llvm::ValueToValueMapTy VMap;
llvm::Function *NewFn = llvm::CloneFunction(BaseFn, VMap);
Index: lib/CodeGen/CGDebugInfo.h
===================================================================
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -308,6 +308,7 @@
~CGDebugInfo();
void finalize();
+ void finalizeSP(llvm::DISubprogram *SP) { DBuilder.finalizeSP(SP); }
/// Module debugging: Support for building PCMs.
/// @{
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33705.100806.patch
Type: text/x-patch
Size: 1058 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170531/f86c185b/attachment.bin>
More information about the cfe-commits
mailing list