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. /// @{
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. /// @{
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits