Page MenuHomePhabricator

[DebugInfo] Add localDecls field to DISubprogram and DILexicalBlock (1/5)
Needs ReviewPublic

Authored by krisb on May 16 2022, 7:55 AM.

Details

Summary

localDecls is intended to track static locals, function- (or lexical-block-) local types (plus typedefs, enums and unions) and imported entities.
Main motivation for adding new field for DISubprogram and DILexicalBlock is to implement more accurate handling for function-local declarations (types, imports and static locals) and support lexical block scopes for them (see D125693).

Thus static locals, function-local enums and imported entities are no longer go to compile unit's 'globals', 'enums' and 'imports'.
But if '-debug-info-kind' is specified as 'unused-types', function-local type-like entities will be referenced by CUs 'retainedTypes'.

This patch just adds localDecls field, corresponding clang/backend changes are in next patches.

Diff Detail

Unit TestsFailed

TimeTest
60,080 msx64 debian > AddressSanitizer-x86_64-linux-dynamic.TestCases::scariness_score_test.cpp
Script: -- : 'RUN: at line 4'; /var/lib/buildkite-agent/builds/llvm-project/build/./bin/clang --driver-mode=g++ -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only -m64 -shared-libasan -O0 /var/lib/buildkite-agent/builds/llvm-project/compiler-rt/test/asan/TestCases/scariness_score_test.cpp -o /var/lib/buildkite-agent/builds/llvm-project/build/projects/compiler-rt/test/asan/X86_64LinuxDynamicConfig/TestCases/Output/scariness_score_test.cpp.tmp
60,080 msx64 debian > AddressSanitizer-x86_64-linux.TestCases::scariness_score_test.cpp
Script: -- : 'RUN: at line 4'; /var/lib/buildkite-agent/builds/llvm-project/build/./bin/clang --driver-mode=g++ -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only -m64 -O0 /var/lib/buildkite-agent/builds/llvm-project/compiler-rt/test/asan/TestCases/scariness_score_test.cpp -o /var/lib/buildkite-agent/builds/llvm-project/build/projects/compiler-rt/test/asan/X86_64LinuxConfig/TestCases/Output/scariness_score_test.cpp.tmp

Event Timeline

krisb created this revision.May 16 2022, 7:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 16 2022, 7:55 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
krisb requested review of this revision.May 16 2022, 7:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 16 2022, 7:55 AM
ormris removed a subscriber: ormris.May 16 2022, 11:08 AM
krisb edited the summary of this revision. (Show Details)May 23 2022, 3:15 AM
krisb updated this revision to Diff 431320.May 23 2022, 3:35 AM

Fix comment.

krisb retitled this revision from [DebugInfo][WIP] Add localDecls field to DISubprogram and DILexicalBlock (1/5) to [DebugInfo] Add localDecls field to DISubprogram and DILexicalBlock (1/5).Mon, Jun 13, 2:30 AM

Do you need to add any special handling to CloneFunction.cpp or will it work correctly?

krisb added a comment.Tue, Jun 14, 2:45 AM

Do you need to add any special handling to CloneFunction.cpp or will it work correctly?

It will work correctly.
D125693 has a test case that checks that a function with 2 local 'global' variables gets properly cloned.

There is a corner case, though. It doesn't directly relate to this patch, but still needs to be mentioned. If to clone a function with other functions inlined into it within the same module, DISubprograms of the inlined functions will not be cloned. But DILexicalBlocks in scopes of such inlined functions will be duplicated which may cause problems later in AsmPrinter. D127102 proposes to skip cloning DILexicalBlocks if their parent DISubprogram was not cloned.