-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[llvm][AsmPrinter] Emit call graph section #87576
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
Prabhuk
wants to merge
44
commits into
users/Prabhuk/sprmain.asmprintercallgraphsection-emit-call-graph-section-4
Choose a base branch
from
users/Prabhuk/sprasmprintercallgraphsection-emit-call-graph-section-4
base: users/Prabhuk/sprmain.asmprintercallgraphsection-emit-call-graph-section-4
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.
Open
Changes from all commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
d163d80
[𝘀𝗽𝗿] initial version
necipfazil dd26405
Updated fixme on PR 87570
necipfazil b5b03fd
Rebased on top of main
necipfazil b90a4d5
dyn_cast to isa
necipfazil 332f2aa
Rebased on upstream main.
necipfazil 1209081
Rebase patchset
necipfazil 1981340
Update inline comment as suggested.
necipfazil 423d5f2
Addressed review comments.
necipfazil e51ce07
Rebase on top of upstream main.
necipfazil e4684b8
Break clang and llvm parts into separate commits.
necipfazil 7f15e6b
Reorder commits.
necipfazil 3fad066
Rebase on top of main.
necipfazil 1fd9775
Rename OB_type to OB_callee_type.
necipfazil 2f763c0
Rebase on top of main
necipfazil 5e6675b
Update IR verifier.
necipfazil 39e5b93
Add requested tests part 1.
necipfazil f18f492
Update comments in tests.
necipfazil 6b67376
Updated the test as reviewers suggested.
necipfazil d2bb381
Scoped enum. Simplify test.
necipfazil e3c95b5
Remove unnecessary cast.
necipfazil 835c2e2
Remove unnecessary asserts. Remove autos for better readability.
necipfazil 678008e
Reorder IR metadata and rename temporary var names in test.
necipfazil 5831ed4
Add RISC-V support. Clean up test files.
necipfazil 77ce9ab
Clean up test files.
necipfazil 7d8418c
Address code refactoring comments.
necipfazil 19043db
Use CalleeTypeIds list to emit callgraph section.
necipfazil 0754d49
Address review comments.
necipfazil cf2e510
Extract callsite label emission as a private method.
necipfazil 80df0c0
Address review comments.
necipfazil 20679e7
Address review comments.
necipfazil 48e878c
Address review comments.
necipfazil aeaa155
Separate the assembly test for callgraph section and related labels i…
necipfazil f248de4
Rebase on parent.
necipfazil 516dee0
Add llvm-mc test. Address comments.
necipfazil b45026e
Update test inline comments.
necipfazil 106364f
Rebase on parent.
necipfazil 9a561db
Rebase on parent.
necipfazil 5778238
Rebase on parent change.
necipfazil caae8ac
Remove dso_local and noundef from tests.
necipfazil dcf4495
Rebase on parent.
necipfazil 9d25b19
Rebase on parent
necipfazil 837e254
Rebase on main.
necipfazil 65a4435
Drop local_unnamed_addr.
necipfazil e1e3fd1
Rebase change.
necipfazil 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
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,60 @@ | ||
;; Test if temporary labels are generated for each indirect callsite with a callee_type metadata. | ||
;; Test if the .callgraph section contains the numerical callee type id for each of the temporary | ||
;; labels generated. | ||
|
||
; RUN: llc -mtriple=x86_64-unknown-linux --call-graph-section -o - < %s | FileCheck %s | ||
|
||
declare !type !0 void @foo() | ||
|
||
declare !type !1 i32 @bar(i8 signext) | ||
|
||
declare !type !2 ptr @baz(ptr) | ||
|
||
; CHECK: ball: | ||
; CHECK-NEXT: .Lfunc_begin0: | ||
define void @ball() { | ||
entry: | ||
%retval = alloca i32, align 4 | ||
%fp_foo = alloca ptr, align 8 | ||
%a = alloca i8, align 1 | ||
%fp_bar = alloca ptr, align 8 | ||
%fp_baz = alloca ptr, align 8 | ||
store i32 0, ptr %retval, align 4 | ||
store ptr @foo, ptr %fp_foo, align 8 | ||
%fp_foo_val = load ptr, ptr %fp_foo, align 8 | ||
; CHECK: .Ltmp0: | ||
call void (...) %fp_foo_val(), !callee_type !1 | ||
store ptr @bar, ptr %fp_bar, align 8 | ||
%fp_bar_val = load ptr, ptr %fp_bar, align 8 | ||
%a_val = load i8, ptr %a, align 1 | ||
; CHECK: .Ltmp1: | ||
%call_fp_bar = call i32 %fp_bar_val(i8 signext %a_val), !callee_type !3 | ||
store ptr @baz, ptr %fp_baz, align 8 | ||
%fp_baz_val = load ptr, ptr %fp_baz, align 8 | ||
; CHECK: .Ltmp2: | ||
%call_fp_baz = call ptr %fp_baz_val(ptr %a), !callee_type !5 | ||
call void @foo() | ||
%a_val_2 = load i8, ptr %a, align 1 | ||
%call_bar = call i32 @bar(i8 signext %a_val_2) | ||
%call_baz = call ptr @baz(ptr %a) | ||
ret void | ||
} | ||
|
||
; CHECK: .section .callgraph,"o",@progbits,.text | ||
|
||
; CHECK-NEXT: .quad 0 | ||
; CHECK-NEXT: .quad .Lfunc_begin0 | ||
; CHECK-NEXT: .quad 1 | ||
; CHECK-NEXT: .quad 3 | ||
; CHECK-NEXT: .quad 4524972987496481828 | ||
; CHECK-NEXT: .quad .Ltmp0 | ||
!0 = !{i64 0, !"_ZTSFvE.generalized"} | ||
!1 = !{!0} | ||
; CHECK-NEXT: .quad 3498816979441845844 | ||
; CHECK-NEXT: .quad .Ltmp1 | ||
!2 = !{i64 0, !"_ZTSFicE.generalized"} | ||
!3 = !{!2} | ||
; CHECK-NEXT: .quad 8646233951371320954 | ||
; CHECK-NEXT: .quad .Ltmp2 | ||
!4 = !{i64 0, !"_ZTSFPvS_E.generalized"} | ||
!5 = !{!4} |
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,34 @@ | ||
;; Tests that we store the type identifiers in .callgraph section of the object file for tailcalls. | ||
|
||
; RUN: llc -mtriple=x86_64-unknown-linux --call-graph-section -filetype=obj -o - < %s | \ | ||
; RUN: llvm-readelf -x .callgraph - | FileCheck %s | ||
|
||
define i32 @_Z13call_indirectPFicEc(ptr %func, i8 %x) !type !0 { | ||
entry: | ||
%call = tail call i32 %func(i8 signext %x), !callee_type !1 | ||
ret i32 %call | ||
} | ||
|
||
define i32 @main(i32 %argc) !type !3 { | ||
entry: | ||
%0 = and i32 %argc, 1 | ||
%cmp = icmp eq i32 %0, 0 | ||
%_Z3fooc._Z3barc = select i1 %cmp, ptr @_Z3fooc, ptr @_Z3barc | ||
%call.i = tail call i32 %_Z3fooc._Z3barc(i8 signext 97), !callee_type !1 | ||
ret i32 %call.i | ||
} | ||
|
||
declare !type !2 i32 @_Z3fooc(i8 signext) | ||
|
||
declare !type !2 i32 @_Z3barc(i8 signext) | ||
|
||
;; Check that the numeric type id (md5 hash) for the below type ids are emitted | ||
;; to the callgraph section. | ||
|
||
; CHECK: Hex dump of section '.callgraph': | ||
|
||
!0 = !{i64 0, !"_ZTSFiPvcE.generalized"} | ||
!1 = !{!2} | ||
; CHECK-DAG: 5486bc59 814b8e30 | ||
!2 = !{i64 0, !"_ZTSFicE.generalized"} | ||
!3 = !{i64 0, !"_ZTSFiiE.generalized"} |
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.
Uh oh!
There was an error while loading. Please reload this page.