[PATCH] D18477: Drop debug info for DISubprograms that are not referenced by anything
Adrian Prantl via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 7 10:07:15 PDT 2016
> On Apr 6, 2016, at 11:07 PM, Duncan P. N. Exon Smith <dexonsmith at apple.com> wrote:
>
>
>> On 2016-Apr-06, at 17:09, Adrian Prantl <aprantl at apple.com> wrote:
>>
>> aprantl added a comment.
>>
>> Ping.
>>
>>
>> http://reviews.llvm.org/D18477
>
> There's something I don't quite understand in the DwarfDebug.cpp which
> I point out below. Heading out on vacation, so I'm happy to defer to
> Eric/David/you/etc. if it makes sense (LGTM once others are happy).
>
>> Index: lib/CodeGen/AsmPrinter/DwarfDebug.cpp
>> ===================================================================
>> --- lib/CodeGen/AsmPrinter/DwarfDebug.cpp
>> +++ lib/CodeGen/AsmPrinter/DwarfDebug.cpp
>> @@ -527,29 +527,10 @@
>>
>> void DwarfDebug::finishSubprogramDefinitions() {
>> for (const auto &P : SPMap)
>> - forBothCUs(*P.second, [&](DwarfCompileUnit &CU) {
>> - CU.finishSubprogramDefinition(cast<DISubprogram>(P.first));
>> - });
>> -}
>> -
>> -// Collect info for variables that were optimized out.
>> -void DwarfDebug::collectDeadVariables() {
>> - const Module *M = MMI->getModule();
>> -
>> - if (NamedMDNode *CU_Nodes = M->getNamedMetadata("llvm.dbg.cu")) {
>> - for (MDNode *N : CU_Nodes->operands()) {
>> - auto *TheCU = cast<DICompileUnit>(N);
>> - // Construct subprogram DIE and add variables DIEs.
>> - DwarfCompileUnit *SPCU =
>> - static_cast<DwarfCompileUnit *>(CUMap.lookup(TheCU));
>> - assert(SPCU && "Unable to find Compile Unit!");
>> - for (auto *SP : TheCU->getSubprograms()) {
>> - if (ProcessedSPNodes.count(SP) != 0)
>> - continue;
>> - SPCU->collectDeadVariables(SP);
>> - }
>> - }
>> - }
>> + if (ProcessedSPNodes.count(P.first))
>> + forBothCUs(*P.second, [&](DwarfCompileUnit &CU) {
>> + CU.finishSubprogramDefinition(cast<DISubprogram>(P.first));
>> + });
>
> ^ remember this...
>
>> }
>>
>> void DwarfDebug::finalizeModuleInfo() {
>> @@ -559,9 +540,6 @@
>>
>> finishVariableDefinitions();
>>
>> - // Collect info for variables that were optimized out.
>> - collectDeadVariables();
>> -
>> // Handle anything that needs to be done on a per-unit basis after
>> // all other generation.
>> for (const auto &P : CUMap) {
>> @@ -1121,6 +1099,10 @@
>> PrevCU = nullptr;
>> CurFn = nullptr;
>> DebugHandlerBase::endFunction(MF);
>> + // Mark functions with no debug info on any instructions, but a
>> + // valid DISubprogram as processed.
>> + if (auto *SP = MF->getFunction()->getSubprogram())
>> + ProcessedSPNodes.insert(SP);
>
> Why do you want to run the above code for these subprograms?
> Don't you want to skip them entirely?
The comment is describing the situation in DebugInfo/X86/dbg-file-name.ll
; Verify that the file name is relative to the directory.
; rdar://problem/8884898
; CHECK: file 1 "simple.c"
define i32 @main() nounwind !dbg !6 {
ret i32 0
}
!6 = distinct !DISubprogram(name: "main", linkageName: "main", line: 9, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, file: !10, scope: !1, type: !7)
where a function has a DISubprogram attached to it, but none of its instructions have a valid location. We still want to emit an SP DIE for these functions. (Or at least we have done so in the past).
-- adrian
>
>> return;
>> }
>>
>>
>
More information about the llvm-commits
mailing list