Front-end part for production of DISubprogram of an external function necessary for DWARF info about call sites.
Authors: @asowda, @NikolaPrica, @djtodoro, @ivanbaev
Differential D60714
[clang] Add DISuprogram and DIE for func decl of an external djtodoro on Apr 15 2019, 8:40 AM. Authored by
Details Front-end part for production of DISubprogram of an external function necessary for DWARF info about call sites. Authors: @asowda, @NikolaPrica, @djtodoro, @ivanbaev
Diff Detail
Event Timeline
Comment Actions Thanks for all your responses. I think the only thing left to do here is to factor out all the CGDebugInfo-related code into a CGDebugInfo::handleFunctionCall() (or similarly named) method, so all the debug info code is contained in CGDebugInfo.cpp. Comment Actions (I apologize if I keep asking the same questions over and over again.)
Comment Actions @aprantl Since this is a very big feature, we want to clarify everything as well, so everything is OK. :) Actually, I think that we have a small misunderstanding about this part. SPFlagDeclForCallSite is used just to mark a DISubprogram as declaration for call site. It will be emitted only in the case if subprogram of a function is not there at the moment (if (!Func->getSubprogram()). So, it is the case only for extern functions. We are doing this in order to avoid ‘DW_TAG_call_site’ with no ‘call_reference’ attribute set. GCC does the same. This part improves existing call site debug info in LLVM.
Comment Actions That's what wasn't quite clear to me: When the call site of a (internal or linkonce-odr) function is visited before the function bode is code-generated, what happens? Do we end up with two DISubprograms, one with a forward decl and one with the real definition? Will we end up with a DISubprogram with a definition *and* an SPFlagDeclForCallSite?
Are you saying that without the extra forward declarations emitted by this patch, we would generate DW_TAG_call_site entries that don't have a DW_AT_call_origin attribute? Or something else?
IIUC, that makes sense to me. Comment Actions
At this place functions are already visited, so every function with its body has DISubprogram set up. But, if somewhere out there is the example like that, we will have two DISubprograms generated.
Yes, you understand it right. We see that it is missing in some cases by using the latest version of LLVM. Comment Actions Good :-)
Comment Actions LGTM with three nitpicks inside.
Comment Actions -Address suggestions Comment Actions -Handle the TargetDecl in more secure way (the same as the other code in the function) |