-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Reapply "[Clang,debuginfo] added vtt parameter in destructor DISubroutineType (#130674)" #145697
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
Open
rnk
wants to merge
2
commits into
llvm:main
Choose a base branch
from
rnk:reland-vtt2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
…tineType (llvm#130674)" This reverts commit cd826d6.
@llvm/pr-subscribers-debuginfo @llvm/pr-subscribers-clang-codegen Author: Reid Kleckner (rnk) ChangesThis reverts commit cd826d6. I tweaked the code to avoid an OOB, but I'm not 100% confident that it is correct. Full diff: https://github.com/llvm/llvm-project/pull/145697.diff 3 Files Affected:
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index ee5e3d68a5ffa..51dd14aa21c13 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2106,8 +2106,17 @@ CGDebugInfo::getOrCreateMethodType(const CXXMethodDecl *Method,
return getOrCreateInstanceMethodType(ThisType, Func, Unit);
}
-llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType(
- QualType ThisPtr, const FunctionProtoType *Func, llvm::DIFile *Unit) {
+llvm::DISubroutineType *CGDebugInfo::getOrCreateMethodTypeForDestructor(
+ const CXXMethodDecl *Method, llvm::DIFile *Unit, QualType FNType) {
+ const FunctionProtoType *Func = FNType->getAs<FunctionProtoType>();
+ // skip the first param since it is also this
+ return getOrCreateInstanceMethodType(Method->getThisType(), Func, Unit, true);
+}
+
+llvm::DISubroutineType *
+CGDebugInfo::getOrCreateInstanceMethodType(QualType ThisPtr,
+ const FunctionProtoType *Func,
+ llvm::DIFile *Unit, bool SkipFirst) {
FunctionProtoType::ExtProtoInfo EPI = Func->getExtProtoInfo();
Qualifiers &Qc = EPI.TypeQuals;
Qc.removeConst();
@@ -2147,7 +2156,7 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType(
}
// Copy rest of the arguments.
- for (unsigned i = 1, e = Args.size(); i != e; ++i)
+ for (unsigned i = (SkipFirst ? 2 : 1), e = Args.size(); i < e; ++i)
Elts.push_back(Args[i]);
// Attach FlagObjectPointer to the explicit "this" parameter.
@@ -4517,6 +4526,12 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateFunctionType(const Decl *D,
// subprogram DIE will miss DW_AT_decl_file and DW_AT_decl_line fields.
return DBuilder.createSubroutineType(DBuilder.getOrCreateTypeArray({}));
+ if (const auto *Method = dyn_cast<CXXDestructorDecl>(D)) {
+ // Read method type from 'FnType' because 'D.getType()' does not cover
+ // implicit arguments for destructors.
+ return getOrCreateMethodTypeForDestructor(Method, F, FnType);
+ }
+
if (const auto *Method = dyn_cast<CXXMethodDecl>(D))
return getOrCreateMethodType(Method, F);
diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h
index 16759f25123cd..411b2e718da30 100644
--- a/clang/lib/CodeGen/CGDebugInfo.h
+++ b/clang/lib/CodeGen/CGDebugInfo.h
@@ -263,9 +263,14 @@ class CGDebugInfo {
/// to get a method type which includes \c this pointer.
llvm::DISubroutineType *getOrCreateMethodType(const CXXMethodDecl *Method,
llvm::DIFile *F);
+
+ llvm::DISubroutineType *
+ getOrCreateMethodTypeForDestructor(const CXXMethodDecl *Method,
+ llvm::DIFile *F, QualType FNType);
+
llvm::DISubroutineType *
getOrCreateInstanceMethodType(QualType ThisPtr, const FunctionProtoType *Func,
- llvm::DIFile *Unit);
+ llvm::DIFile *Unit, bool SkipFirst = false);
llvm::DISubroutineType *
getOrCreateFunctionType(const Decl *D, QualType FnType, llvm::DIFile *F);
/// \return debug info descriptor for vtable.
diff --git a/clang/test/CodeGenCXX/debug-info-dtor-implicit-args.cpp b/clang/test/CodeGenCXX/debug-info-dtor-implicit-args.cpp
new file mode 100644
index 0000000000000..4bb51dcc4da51
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-dtor-implicit-args.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -triple x86_64-none-linux-gnu -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -emit-llvm -debug-info-kind=limited %s -o - | FileCheck --check-prefix MSVC %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]]}
+
+// MSVC-DAG: ![[inttype:[0-9]+]] = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+// MSVC-DAG: ![[voidpointertype:[0-9]+]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
+// MSVC-DAG: ![[destructor:[0-9]+]] = distinct !DISubprogram(name: "~A", linkageName: "??_GA@@UEAAPEAXI@Z", {{.*}}, type: ![[subroutinetype:[0-9]+]]
+// MSVC-DAG: !{{[0-9]+}} = !DILocalVariable(name: "should_call_delete", arg: 2, scope: ![[destructor]], type: ![[inttype]], flags: DIFlagArtificial)
+// MSVC-DAG: ![[subroutinetype]] = !DISubroutineType(types: ![[types:[0-9]+]])
+// MSVC-DAG: [[types]] = !{![[voidpointertype]], !{{[0-9]+}}, ![[inttype]]}
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
clang:codegen
IR generation bugs: mangling, exceptions, etc.
clang
Clang issues not falling into any other category
debuginfo
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.
This reverts commit cd826d6 and relands 27c1aa9
This fixes #104765
I tweaked the code to avoid an OOB, but I'm not 100% confident that it is correct.