-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[Clang,debuginfo] added vtt parameter in destructor DISubroutineType #130674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
017a07e
[Clang,debuginfo] added vtt parameter in DISubroutineType for virtual…
mgschossmann cdd8eb8
fixed test
mgschossmann 803460d
test: fixed target triple to x86_64-none-linux-gnu (vtt not generated…
mgschossmann 2853c57
added test for msvc
mgschossmann 909d340
added comment
mgschossmann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// RUN: %clang_cc1 -triple x86_64-none-linux-gnu -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s | ||
|
||
struct B { | ||
virtual ~B() {} | ||
}; | ||
|
||
struct A : virtual B { | ||
}; | ||
|
||
A a; | ||
|
||
|
||
// CHECK-DAG: !{{[0-9]+}} = !DILocalVariable(name: "vtt", arg: 2, scope: ![[destructor:[0-9]+]], type: ![[vtttype:[0-9]+]], flags: DIFlagArtificial) | ||
// CHECK-DAG: ![[destructor]] = distinct !DISubprogram(name: "~A", {{.*}}, type: ![[subroutinetype:[0-9]+]] | ||
// CHECK-DAG: ![[subroutinetype]] = !DISubroutineType(types: ![[types:[0-9]+]]) | ||
// CHECK-DAG: [[types]] = !{null, !{{[0-9]+}}, ![[vtttype]]} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a test for the MSVC ABI, since I don't think it has VTT parameters, and I'm not sure the code you added does the right thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your comment. Indeed, my code changes behavior when compiling for i686-pc-windows-msvc, which I did not expect.
However, there seems to be the same problem: There is an implicit parameter
should_call_delete
, whoseDILocalVariable
hasarg: 2
even though there is no second argument in the function type'stypes
array. Similarly tovtt
, the patched code adds this parameter to the array.Additionally, it changes the return type of the destructor to a void pointer. I am unsure, why this happens, since that does not happen on ItaniumABI. Does the MSVC ABI feature an implicit void return? Unfortunately, I am lacking knowledge of the MSVC ABI to be able to judge what the correct behavior should be.
Following are clang outputs for
debug-info-vtt.cpp
:clang_outputs.zip
PS: I am unsure whether the bug is that the AST is not correctly updated in
clang/lib/CodeGen/ItaniumCXXABI.cpp
(andclang/lib/CodeGen/MicrosoftCXXABI.cpp
) or that the AST is not correctly read inclang/lib/CodeGen/CGDebugInfo.cpp
. In the former case, my patch feels like a workaround.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I looked at the files, and I think the new debug info looks good, it adds a DISubroutineType int parameter.
However, I don't understand why the patch you've posted here has that effect. Do you have more local changes? Why does skipping more arguments in this loop create more subroutine parameter types? I'm struggling to understand, and I just assumed adding more testing would provide answers to these questions.
Please do create a test case out of the IR you shared, it does seem relevant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The key change of this pull request is that debug info for destructors is now taken from
FNType
instead ofD->getType()
/Method->getType()
.Method->getType()
does not include the implicit arguments, whileFNType
does.FNType
however also includes thethis
argument. In order to prevent duplicate emission ofthis
, the pull request introduces theSkipFirst
argument ingetOrCreateInstanceMethodType
.I now also added a test for MSVC, which checks for presence of the
should_call_delete
arg. It also enforces that the return value bevoid*
. The new test seems to pass, however there seems to be an issue in the CI, so it is reported as failed.