-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[clang][DebugInfo] Add virtual call-site target information in DWARF. #167666
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
CarlosAlbertoEnciso
wants to merge
5
commits into
llvm:main
Choose a base branch
from
CarlosAlbertoEnciso:callsite-indirect-calls
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.
+515
−20
Open
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1899490
[clang][DebugInfo] Add virtual call-site target information in DWARF.
CarlosAlbertoEnciso 96678f3
[clang][DebugInfo] Add virtual call-site target information in DWARF.
CarlosAlbertoEnciso 4ec56ac
[clang][DebugInfo] Add virtual call-site target information in DWARF.
CarlosAlbertoEnciso 7837b84
[clang][DebugInfo] Add virtual call-site target information in DWARF.
CarlosAlbertoEnciso 7df69b4
[clang][DebugInfo] Add virtual call-site target information in DWARF.
CarlosAlbertoEnciso 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
Some comments aren't visible on the classic Files Changed page.
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -682,6 +682,15 @@ class CGDebugInfo { | |||||
| /// that it is supported and enabled. | ||||||
| llvm::DINode::DIFlags getCallSiteRelatedAttrs() const; | ||||||
|
|
||||||
| /// Add call target information. | ||||||
| void addCallTarget(StringRef Name, llvm::MDNode *MD, llvm::CallBase *CI); | ||||||
| void addCallTarget(llvm::Function *F, const FunctionDecl *FD, | ||||||
| llvm::CallBase *CI); | ||||||
|
|
||||||
| /// Remove a call target entry for the given name or function. | ||||||
| void removeCallTarget(StringRef Name); | ||||||
| void removeCallTarget(llvm::Function *F); | ||||||
|
|
||||||
| private: | ||||||
| /// Amend \p I's DebugLoc with \p Group (its source atom group) and \p | ||||||
| /// Rank (lower nonzero rank is higher precedence). Does nothing if \p I | ||||||
|
|
@@ -903,6 +912,25 @@ class CGDebugInfo { | |||||
| /// If one exists, returns the linkage name of the specified \ | ||||||
| /// (non-null) \c Method. Returns empty string otherwise. | ||||||
| llvm::StringRef GetMethodLinkageName(const CXXMethodDecl *Method) const; | ||||||
|
|
||||||
| /// For each 'DISuprogram' we store a list of call instructions 'CallBase' | ||||||
| /// that indirectly call such 'DISuprogram'. We use its linkage name to | ||||||
|
||||||
| /// that indirectly call such 'DISuprogram'. We use its linkage name to | |
| /// that indirectly call such 'DISuprogram'. We use its linkage name to |
CarlosAlbertoEnciso marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
CarlosAlbertoEnciso marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
CarlosAlbertoEnciso marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
CarlosAlbertoEnciso marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
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,36 @@ | ||
| // Simple class with only virtual methods: inlined and not-inlined | ||
| // We check for a generated 'call_target' for: | ||
| // - 'one', 'two' and 'three'. | ||
|
|
||
| class CBase { | ||
| public: | ||
| virtual void one(); | ||
| virtual void two(); | ||
| virtual void three() {} | ||
| }; | ||
| void CBase::one() {} | ||
|
|
||
| void bar(CBase *Base) { | ||
| Base->one(); | ||
| Base->two(); | ||
| Base->three(); | ||
|
|
||
| CBase B; | ||
| B.one(); | ||
| } | ||
|
|
||
| // RUN: %clang_cc1 -triple=x86_64-linux -disable-llvm-passes -emit-llvm \ | ||
| // RUN: -debug-info-kind=constructor -dwarf-version=5 -O1 %s \ | ||
| // RUN: -o - | FileCheck %s -check-prefix CHECK-BASE | ||
CarlosAlbertoEnciso marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| // CHECK-BASE: define {{.*}} @_Z3barP5CBase{{.*}} { | ||
| // CHECK-BASE-DAG: call void %1{{.*}} !dbg {{![0-9]+}}, !call_target [[BASE_ONE:![0-9]+]] | ||
| // CHECK-BASE-DAG: call void %3{{.*}} !dbg {{![0-9]+}}, !call_target [[BASE_TWO:![0-9]+]] | ||
| // CHECK-BASE-DAG: call void %5{{.*}} !dbg {{![0-9]+}}, !call_target [[BASE_THREE:![0-9]+]] | ||
| // CHECK-BASE-DAG: call void @_ZN5CBaseC2Ev{{.*}} !dbg {{![0-9]+}} | ||
| // CHECK-BASE-DAG: call void @_ZN5CBase3oneEv{{.*}} !dbg {{![0-9]+}} | ||
CarlosAlbertoEnciso marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // CHECK-BASE: } | ||
|
|
||
| // CHECK-BASE-DAG: [[BASE_ONE]] = {{.*}}!DISubprogram(name: "one", linkageName: "_ZN5CBase3oneEv" | ||
| // CHECK-BASE-DAG: [[BASE_TWO]] = {{.*}}!DISubprogram(name: "two", linkageName: "_ZN5CBase3twoEv" | ||
| // CHECK-BASE-DAG: [[BASE_THREE]] = {{.*}}!DISubprogram(name: "three", linkageName: "_ZN5CBase5threeEv" | ||
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,77 @@ | ||
| // Simple base and derived class with virtual and static methods: | ||
| // We check for a generated 'call_target' for: | ||
| // - 'one', 'two' and 'three'. | ||
|
|
||
| class CBase { | ||
| public: | ||
| virtual void one(bool Flag) {} | ||
| virtual void two(int P1, char P2) {} | ||
| static void three(); | ||
| }; | ||
|
|
||
| void CBase::three() { | ||
| } | ||
| void bar(CBase *Base); | ||
|
|
||
| void foo(CBase *Base) { | ||
| CBase::three(); | ||
| } | ||
|
|
||
| class CDerived : public CBase { | ||
| public: | ||
| void one(bool Flag) {} | ||
| void two(int P1, char P2) {} | ||
| }; | ||
| void foo(CDerived *Derived); | ||
|
|
||
| int main() { | ||
| CBase B; | ||
| bar(&B); | ||
|
|
||
| CDerived D; | ||
| foo(&D); | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| void bar(CBase *Base) { | ||
| Base->two(77, 'a'); | ||
| } | ||
|
|
||
| void foo(CDerived *Derived) { | ||
| Derived->one(true); | ||
| } | ||
|
|
||
| // RUN: %clang_cc1 -triple=x86_64-linux -disable-llvm-passes -emit-llvm \ | ||
| // RUN: -debug-info-kind=constructor -dwarf-version=5 -O1 %s \ | ||
| // RUN: -o - | FileCheck %s -check-prefix CHECK-DERIVED | ||
|
|
||
| // CHECK-DERIVED: define {{.*}} @_Z3fooP5CBase{{.*}} { | ||
| // CHECK-DERIVED-DAG: call void @_ZN5CBase5threeEv{{.*}} !dbg {{![0-9]+}} | ||
| // CHECK-DERIVED: } | ||
|
|
||
| // CHECK-DERIVED: define {{.*}} @main{{.*}} { | ||
| // CHECK-DERIVED-DAG: call void @_ZN5CBaseC1Ev{{.*}} !dbg {{![0-9]+}} | ||
| // CHECK-DERIVED-DAG: call void @_Z3barP5CBase{{.*}} !dbg {{![0-9]+}} | ||
| // CHECK-DERIVED-DAG: call void @_ZN8CDerivedC1Ev{{.*}} !dbg {{![0-9]+}} | ||
| // CHECK-DERIVED-DAG: call void @_Z3fooP8CDerived{{.*}} !dbg {{![0-9]+}} | ||
| // CHECK-DERIVED: } | ||
|
|
||
| // CHECK-DERIVED: define {{.*}} @_ZN5CBaseC1Ev{{.*}} { | ||
| // CHECK-DERIVED-DAG: call void @_ZN5CBaseC2Ev{{.*}} !dbg {{![0-9]+}} | ||
| // CHECK-DERIVED: } | ||
|
|
||
| // CHECK-DERIVED: define {{.*}} @_Z3barP5CBase{{.*}} { | ||
| // CHECK-DERIVED-DAG: call void %1{{.*}} !dbg {{![0-9]+}}, !call_target [[BASE_TWO:![0-9]+]] | ||
| // CHECK-DERIVED: } | ||
|
|
||
| // CHECK-DERIVED: define {{.*}} @_ZN8CDerivedC1Ev{{.*}} { | ||
| // CHECK-DERIVED-DAG: call void @_ZN8CDerivedC2Ev{{.*}} !dbg {{![0-9]+}} | ||
| // CHECK-DERIVED: } | ||
|
|
||
| // CHECK-DERIVED: define {{.*}} @_Z3fooP8CDerived{{.*}} { | ||
| // CHECK-DERIVED-DAG: call void %1{{.*}} !dbg {{![0-9]+}}, !call_target [[DERIVED_ONE:![0-9]+]] | ||
| // CHECK-DERIVED: } | ||
|
|
||
| // CHECK-DERIVED-DAG: [[BASE_TWO]] = {{.*}}!DISubprogram(name: "two", linkageName: "_ZN5CBase3twoEic" | ||
| // CHECK-DERIVED-DAG: [[DERIVED_ONE]] = {{.*}}!DISubprogram(name: "one", linkageName: "_ZN8CDerived3oneEb" |
Oops, something went wrong.
Oops, something went wrong.
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.
As of #166202, there's now also a block a bit further down (just before the end, near line 6283) in this
EmitCallfunction that tests for debug info. Maybe move your addition into that block?The block I am referring to also happens to call the slightly different
getDebugInfo()function, which checks whether this specific function has debug info enabled, which seems more correct. (It looks like function-level control of debug info is only changed for lambdas at the moment, so perhaps not a large difference, but good to be consistent I think.)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.
Moving the change into that block it make sense, as they are related.