This is an archive of the discontinued LLVM Phabricator instance.

Switch to using -debug-info-kind=constructor as default (from =limited)
ClosedPublic

Authored by akhuang on Apr 29 2020, 4:36 PM.

Details

Summary

-debug-info-kind=constructor reduces the amount of class debug info that
is emitted; this patch switches to using this as the default.

Constructor homing emits the complete type info for a class only when the
constructor is emitted, so it is expected that there will be some classes that
are not defined in the debug info anymore because they are never constructed,
and we shouldn't need debug info for these classes.

I compared the PDB files for clang, and there are 273 class types that are defined with =limited
but not with =constructor (out of ~60,000 total class types).
We've looked at a number of the types that are no longer defined with =constructor. The vast
majority of cases are something like class A is used as a parameter in a member function of
some other class B, which is emitted. But the function that uses class A is never called, and class A
is never constructed, and therefore isn't emitted in the debug info.

Bug: https://bugs.llvm.org/show_bug.cgi?id=46537

Diff Detail

Event Timeline

akhuang created this revision.Apr 29 2020, 4:36 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptApr 29 2020, 4:36 PM
akhuang updated this revision to Diff 276252.Jul 7 2020, 4:08 PM

Instead of merging =constructor and =limited, change the default to use =constructor

akhuang retitled this revision from [WIP] Merge -debug-info-kind=constructor into -debug-info-kind=limited to Switch to using -debug-info-kind=constructor as default (from =limited).Jul 7 2020, 4:32 PM
akhuang edited the summary of this revision. (Show Details)
akhuang added a reviewer: dblaikie.
dblaikie accepted this revision.Jul 7 2020, 5:11 PM

Could you include some comparative data in the description/commit message demonstrating this generally ends up emitting all the same types for a clang build before/after (& explanations for a sample of any differences)?

This revision is now accepted and ready to land.Jul 7 2020, 5:11 PM
akhuang edited the summary of this revision. (Show Details)Jul 8 2020, 5:13 PM
akhuang edited the summary of this revision. (Show Details)Jul 9 2020, 10:37 AM
akhuang updated this revision to Diff 276778.Jul 9 2020, 10:38 AM

fix one more test case

This revision was automatically updated to reflect the committed changes.
MaskRay added a subscriber: MaskRay.Jul 9 2020, 4:12 PM

Hi, your git commit contains extra Phabricator tags. You can drop Reviewers: Subscribers: Tags: and the text Summary: from the git commit with the following script:

arcfilter () {
        arc amend
        git log -1 --pretty=%B | awk '/Reviewers:|Subscribers:/{p=1} /Reviewed By:|Differential Revision:/{p=0} !p && !/^Summary:$/ {sub(/^Summary: /,"");print}' | git commit --amend --date=now -F -
}

Reviewed By: is considered important by some people. Please keep the tag. (--date=now is my personal preference (author dates are usually not useful. Using committer dates can make log almost monotonic in time))

llvm/utils/git/pre-push.py can validate the message does not include unneeded tags.

Hi,

It looks like is causing one of the debuginfo-tests: llgdb-tests/nrvo-string.cpp to fail, run on Linux. Failure as below. I don't think the debuginfo-tests are run on any bot (but probably should be!). I bisected the failure back to this change.

Please could you take a look?

Thanks
Russ

FAIL: debuginfo-tests :: llgdb-tests/nrvo-string.cpp (1 of 1)
******************** TEST 'debuginfo-tests :: llgdb-tests/nrvo-string.cpp' FAILED ********************
Script:
--
: 'RUN: at line 4';   /home/<user>/git/llvm-project/stage1/bin/clang --driver-mode=g++ -O0 -fno-exceptions --target=x86_64-unknown-linux-gnu /home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/nrvo-string.cpp -o /home/<user>/git/llvm-project/stage1/projects/debuginfo-tests/llgdb-tests/Output/nrvo-string.cpp.tmp.out -g
: 'RUN: at line 5';   /home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/test_debuginfo.pl /home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/nrvo-string.cpp /home/<user>/git/llvm-project/stage1/projects/debuginfo-tests/llgdb-tests/Output/nrvo-string.cpp.tmp.out
: 'RUN: at line 6';   /home/<user>/git/llvm-project/stage1/bin/clang --driver-mode=g++ -O1 -fno-exceptions --target=x86_64-unknown-linux-gnu /home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/nrvo-string.cpp -o /home/<user>/git/llvm-project/stage1/projects/debuginfo-tests/llgdb-tests/Output/nrvo-string.cpp.tmp.out -g
: 'RUN: at line 7';   /home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/test_debuginfo.pl /home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/nrvo-string.cpp /home/<user>/git/llvm-project/stage1/projects/debuginfo-tests/llgdb-tests/Output/nrvo-string.cpp.tmp.out
--
Exit Code: 1

Command Output (stdout):
--
Debugger output was:
Breakpoint 1 at 0x4004f8: file /home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/nrvo-string.cpp, line 23.
Breakpoint 2 at 0x400563: file /home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/nrvo-string.cpp, line 39.

Breakpoint 1, get_string () at /home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/nrvo-string.cpp:23
23        stop();
$1 = 3

Breakpoint 2, get_string2 () at /home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/nrvo-string.cpp:39
39        stop();
/home/<user>/git/llvm-project/stage1/projects/debuginfo-tests/llgdb-tests/Output/nrvo-string.cpp.debugger.script:6: Error in sourced command file:
There is no member named i.

--
Command Output (stderr):
--
/home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/nrvo-string.cpp:52:11: error: CHECK: expected string not found in input
// CHECK: = 5
          ^
/home/<user>/git/llvm-project/stage1/projects/debuginfo-tests/llgdb-tests/Output/nrvo-string.cpp.gdb.output:8:1: note: scanning from here
Breakpoint 2, get_string2 () at /home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/nrvo-string.cpp:39
^
/home/<user>/git/llvm-project/stage1/projects/debuginfo-tests/llgdb-tests/Output/nrvo-string.cpp.gdb.output:8:10: note: possible intended match here
Breakpoint 2, get_string2 () at /home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/nrvo-string.cpp:39
         ^

Input file: /home/<user>/git/llvm-project/stage1/projects/debuginfo-tests/llgdb-tests/Output/nrvo-string.cpp.gdb.output
Check file: /home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/nrvo-string.cpp

-dump-input=help explains the following input dump.

Full input was:
<<<<<<
            1: Breakpoint 1 at 0x4004f8: file /home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/nrvo-string.cpp, line 23.
            2: Breakpoint 2 at 0x400563: file /home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/nrvo-string.cpp, line 39.
            3:
            4: Breakpoint 1, get_string () at /home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/nrvo-string.cpp:23
            5: 23 stop();
            6: $1 = 3
            7:
            8: Breakpoint 2, get_string2 () at /home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/nrvo-string.cpp:39
check:52'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
check:52'1              ?                                                                                                    possible intended match
            9: 39 stop();
check:52'0     ~~~~~~~~~~
           10: /home/<user>/git/llvm-project/stage1/projects/debuginfo-tests/llgdb-tests/Output/nrvo-string.cpp.debugger.script:6: Error in sourced command file:
check:52'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           11: There is no member named i.
check:52'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>>>>

--

Hi,

It looks like is causing one of the debuginfo-tests: llgdb-tests/nrvo-string.cpp to fail, run on Linux. Failure as below. I don't think the debuginfo-tests are run on any bot (but probably should be!). I bisected the failure back to this change.

Please could you take a look?

Thanks
Russ

FAIL: debuginfo-tests :: llgdb-tests/nrvo-string.cpp (1 of 1)
******************** TEST 'debuginfo-tests :: llgdb-tests/nrvo-string.cpp' FAILED ********************
Script:
--
: 'RUN: at line 4';   /home/<user>/git/llvm-project/stage1/bin/clang --driver-mode=g++ -O0 -fno-exceptions --target=x86_64-unknown-linux-gnu /home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/nrvo-string.cpp -o /home/<user>/git/llvm-project/stage1/projects/debuginfo-tests/llgdb-tests/Output/nrvo-string.cpp.tmp.out -g
: 'RUN: at line 5';   /home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/test_debuginfo.pl /home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/nrvo-string.cpp /home/<user>/git/llvm-project/stage1/projects/debuginfo-tests/llgdb-tests/Output/nrvo-string.cpp.tmp.out
: 'RUN: at line 6';   /home/<user>/git/llvm-project/stage1/bin/clang --driver-mode=g++ -O1 -fno-exceptions --target=x86_64-unknown-linux-gnu /home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/nrvo-string.cpp -o /home/<user>/git/llvm-project/stage1/projects/debuginfo-tests/llgdb-tests/Output/nrvo-string.cpp.tmp.out -g
: 'RUN: at line 7';   /home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/test_debuginfo.pl /home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/nrvo-string.cpp /home/<user>/git/llvm-project/stage1/projects/debuginfo-tests/llgdb-tests/Output/nrvo-string.cpp.tmp.out
--
Exit Code: 1

Command Output (stdout):
--
Debugger output was:
Breakpoint 1 at 0x4004f8: file /home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/nrvo-string.cpp, line 23.
Breakpoint 2 at 0x400563: file /home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/nrvo-string.cpp, line 39.

Breakpoint 1, get_string () at /home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/nrvo-string.cpp:23
23        stop();
$1 = 3

Breakpoint 2, get_string2 () at /home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/nrvo-string.cpp:39
39        stop();
/home/<user>/git/llvm-project/stage1/projects/debuginfo-tests/llgdb-tests/Output/nrvo-string.cpp.debugger.script:6: Error in sourced command file:
There is no member named i.

--
Command Output (stderr):
--
/home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/nrvo-string.cpp:52:11: error: CHECK: expected string not found in input
// CHECK: = 5
          ^
/home/<user>/git/llvm-project/stage1/projects/debuginfo-tests/llgdb-tests/Output/nrvo-string.cpp.gdb.output:8:1: note: scanning from here
Breakpoint 2, get_string2 () at /home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/nrvo-string.cpp:39
^
/home/<user>/git/llvm-project/stage1/projects/debuginfo-tests/llgdb-tests/Output/nrvo-string.cpp.gdb.output:8:10: note: possible intended match here
Breakpoint 2, get_string2 () at /home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/nrvo-string.cpp:39
         ^

Input file: /home/<user>/git/llvm-project/stage1/projects/debuginfo-tests/llgdb-tests/Output/nrvo-string.cpp.gdb.output
Check file: /home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/nrvo-string.cpp

-dump-input=help explains the following input dump.

Full input was:
<<<<<<
            1: Breakpoint 1 at 0x4004f8: file /home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/nrvo-string.cpp, line 23.
            2: Breakpoint 2 at 0x400563: file /home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/nrvo-string.cpp, line 39.
            3:
            4: Breakpoint 1, get_string () at /home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/nrvo-string.cpp:23
            5: 23 stop();
            6: $1 = 3
            7:
            8: Breakpoint 2, get_string2 () at /home/<user>/git/llvm-project/debuginfo-tests/llgdb-tests/nrvo-string.cpp:39
check:52'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
check:52'1              ?                                                                                                    possible intended match
            9: 39 stop();
check:52'0     ~~~~~~~~~~
           10: /home/<user>/git/llvm-project/stage1/projects/debuginfo-tests/llgdb-tests/Output/nrvo-string.cpp.debugger.script:6: Error in sourced command file:
check:52'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           11: There is no member named i.
check:52'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>>>>

--

Yep, this looks like a bug in constructor homing (@echristo fyi), here's a reduced test case:

struct t1 {
  t1() = default;
  t1(int);
  int i;
};
t1 v1;

The defaulted default constructor is used, but incorrectly does not home the debug info, producing just this IR:

!6 = !DICompositeType(tag: DW_TAG_structure_type, name: "t1", file: !3, line: 1, flags: DIFlagFwdDecl, identifier: "_ZTS2t1")

Removing the non-default ctor gets the desired type definition:

!6 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t1", file: !3, line: 1, size: 32, flags: DIFlagTypePassByValue, elements: !7, identifier: "_ZTS2t1")