-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[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
Merged
Prabhuk
merged 118 commits into
main
from
users/Prabhuk/sprasmprintercallgraphsection-emit-call-graph-section-4
Jul 31, 2025
Merged
Changes from all commits
Commits
Show all changes
118 commits
Select commit
Hold shift + click to select a range
fbe540b
[𝘀𝗽𝗿] changes to main this commit is based on
necipfazil d163d80
[𝘀𝗽𝗿] initial version
necipfazil 4c15a50
[𝘀𝗽𝗿] changes introduced through rebase
necipfazil dd26405
Updated fixme on PR 87570
necipfazil e7111f0
[𝘀𝗽𝗿] changes introduced through rebase
necipfazil b5b03fd
Rebased on top of main
necipfazil 2b3551e
[𝘀𝗽𝗿] changes introduced through rebase
necipfazil b90a4d5
dyn_cast to isa
necipfazil a692109
[𝘀𝗽𝗿] changes introduced through rebase
necipfazil 332f2aa
Rebased on upstream main.
necipfazil 826c83e
[𝘀𝗽𝗿] changes introduced through rebase
necipfazil 1209081
Rebase patchset
necipfazil 60f93a8
[𝘀𝗽𝗿] changes introduced through rebase
necipfazil 1981340
Update inline comment as suggested.
necipfazil a2daca9
[𝘀𝗽𝗿] changes introduced through rebase
necipfazil 423d5f2
Addressed review comments.
necipfazil 17ee91d
[𝘀𝗽𝗿] changes introduced through rebase
necipfazil e51ce07
Rebase on top of upstream main.
necipfazil 21ec0f7
[𝘀𝗽𝗿] changes introduced through rebase
necipfazil e4684b8
Break clang and llvm parts into separate commits.
necipfazil 5caf81d
[𝘀𝗽𝗿] changes introduced through rebase
necipfazil 7f15e6b
Reorder commits.
necipfazil 2d88d20
[𝘀𝗽𝗿] changes introduced through rebase
necipfazil 3fad066
Rebase on top of main.
necipfazil 1f6e111
[𝘀𝗽𝗿] changes introduced through rebase
necipfazil 1fd9775
Rename OB_type to OB_callee_type.
necipfazil 4615cce
[𝘀𝗽𝗿] changes introduced through rebase
necipfazil 2f763c0
Rebase on top of main
necipfazil 5857d51
[𝘀𝗽𝗿] changes introduced through rebase
necipfazil 5e6675b
Update IR verifier.
necipfazil d9322de
[𝘀𝗽𝗿] changes introduced through rebase
necipfazil 39e5b93
Add requested tests part 1.
necipfazil 6df6234
[𝘀𝗽𝗿] changes introduced through rebase
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 607b992
[𝘀𝗽𝗿] changes introduced through rebase
necipfazil 835c2e2
Remove unnecessary asserts. Remove autos for better readability.
necipfazil 678008e
Reorder IR metadata and rename temporary var names in test.
necipfazil 23f00d0
[𝘀𝗽𝗿] changes introduced through rebase
necipfazil 5831ed4
Add RISC-V support. Clean up test files.
necipfazil a0eb067
[𝘀𝗽𝗿] changes introduced through rebase
necipfazil 77ce9ab
Clean up test files.
necipfazil a4a1171
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 7d8418c
Address code refactoring comments.
necipfazil 42c830f
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 19043db
Use CalleeTypeIds list to emit callgraph section.
necipfazil 4789571
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 0754d49
Address review comments.
necipfazil 86e5b9a
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk cf2e510
Extract callsite label emission as a private method.
necipfazil 4b04333
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 80df0c0
Address review comments.
necipfazil caf45da
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 20679e7
Address review comments.
necipfazil 63e56f2
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 48e878c
Address review comments.
necipfazil d072c83
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk aeaa155
Separate the assembly test for callgraph section and related labels i…
necipfazil a1834c9
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk f248de4
Rebase on parent.
necipfazil 02d721d
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 516dee0
Add llvm-mc test. Address comments.
necipfazil b45026e
Update test inline comments.
necipfazil 370d4f0
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 106364f
Rebase on parent.
necipfazil f1051d5
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 9a561db
Rebase on parent.
necipfazil 4462f6b
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 5778238
Rebase on parent change.
necipfazil 5626438
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk caae8ac
Remove dso_local and noundef from tests.
necipfazil 850fe68
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk dcf4495
Rebase on parent.
necipfazil d651899
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 9d25b19
Rebase on parent
necipfazil 6a0f9b5
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 837e254
Rebase on main.
necipfazil f8f741c
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 65a4435
Drop local_unnamed_addr.
necipfazil 58417bc
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk e1e3fd1
Rebase change.
necipfazil dc9cca4
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 7102170
Rebase.
necipfazil dd8808b
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk aeac1c3
Rebase on parent
necipfazil d332966
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk b95355d
Rebase on top of main.
necipfazil 1975538
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 2397f11
Update hasGeneralizedMDstring API call.
necipfazil 5723d40
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk ceef7e4
Rebase on parent
necipfazil f07f515
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 4422763
Rebase on top of parent change.
necipfazil 52a4b6c
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 317bf8e
Rebase on parent.
necipfazil 73508dd
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 0096eaf
Rebase on parent.
necipfazil f1a4e6c
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk df57b4f
Address review comments.
necipfazil f81b59e
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk d0abedc
Use llvm-reduce to simplify codegen test.
necipfazil 1bd19e6
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 388b958
Rebase.
Prabhuk b94b3e0
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 13efd72
Reduce tests. Update comments in tests.
Prabhuk 2c63a33
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk b327bab
Rebase on main.
Prabhuk 9e6843a
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk f4c8b22
Rebase.
Prabhuk b498381
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk c6cac61
Rebase on parent.
Prabhuk 28bcfbe
Check for .L.* instead of .Ltmp[0-9]+ in test.
Prabhuk a9401f0
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk d0590e9
Rebase on main.
Prabhuk 7a2f29a
Fix inline comments.
Prabhuk 608ba94
Fix alignment in test file.
Prabhuk 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,43 @@ | ||
| ;; Test if temporary labels are generated for each indirect callsite with a callee_type metadata. | ||
| ;; Test if the .callgraph section contains the MD5 hash of callee type ids generated from | ||
| ;; generalized type id strings. | ||
|
|
||
| ; RUN: llc -mtriple=x86_64-unknown-linux --call-graph-section -o - < %s | FileCheck %s | ||
|
|
||
| ; CHECK: ball: | ||
| ; CHECK-NEXT: [[LABEL_FUNC:\.Lfunc_begin[0-9]+]]: | ||
| define ptr @ball() { | ||
| entry: | ||
| %fp_foo_val = load ptr, ptr null, align 8 | ||
| ; CHECK: [[LABEL_TMP0:\.L.*]]: | ||
| call void (...) %fp_foo_val(), !callee_type !0 | ||
| %fp_bar_val = load ptr, ptr null, align 8 | ||
| ; CHECK: [[LABEL_TMP1:\.L.*]]: | ||
| %call_fp_bar = call i32 %fp_bar_val(i8 0), !callee_type !2 | ||
| %fp_baz_val = load ptr, ptr null, align 8 | ||
| ; CHECK: [[LABEL_TMP2:\.L.*]]: | ||
| %call_fp_baz = call ptr %fp_baz_val(ptr null), !callee_type !4 | ||
| ret ptr %call_fp_baz | ||
| } | ||
|
|
||
| ; CHECK: .section .callgraph,"o",@progbits,.text | ||
|
|
||
| ; CHECK-NEXT: .quad 0 | ||
| ; CHECK-NEXT: .quad [[LABEL_FUNC]] | ||
| ; CHECK-NEXT: .quad 1 | ||
| ; CHECK-NEXT: .quad 3 | ||
| !0 = !{!1} | ||
| !1 = !{i64 0, !"_ZTSFvE.generalized"} | ||
| ;; Test for MD5 hash of _ZTSFvE.generalized and the generated temporary callsite label. | ||
| ; CHECK-NEXT: .quad 4524972987496481828 | ||
| ; CHECK-NEXT: .quad [[LABEL_TMP0]] | ||
| !2 = !{!3} | ||
| !3 = !{i64 0, !"_ZTSFicE.generalized"} | ||
| ;; Test for MD5 hash of _ZTSFicE.generalized and the generated temporary callsite label. | ||
| ; CHECK-NEXT: .quad 3498816979441845844 | ||
| ; CHECK-NEXT: .quad [[LABEL_TMP1]] | ||
| !4 = !{!5} | ||
| !5 = !{i64 0, !"_ZTSFPvS_E.generalized"} | ||
| ;; Test for MD5 hash of _ZTSFPvS_E.generalized and the generated temporary callsite label. | ||
| ; CHECK-NEXT: .quad 8646233951371320954 | ||
| ; CHECK-NEXT: .quad [[LABEL_TMP2]] |
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 @check_tailcall(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: | ||
| %andop = and i32 %argc, 1 | ||
| %cmp = icmp eq i32 %andop, 0 | ||
| %foo.bar = select i1 %cmp, ptr @foo, ptr @bar | ||
| %call.i = tail call i32 %foo.bar(i8 signext 97), !callee_type !1 | ||
| ret i32 %call.i | ||
| } | ||
|
|
||
| declare !type !2 i32 @foo(i8 signext) | ||
|
|
||
| declare !type !2 i32 @bar(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"} |
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,38 @@ | ||
| ;; Tests that we store the type identifiers in .callgraph section of the object file. | ||
|
|
||
| ; RUN: llc -mtriple=x86_64-unknown-linux --call-graph-section -filetype=obj -o - < %s | \ | ||
| ; RUN: llvm-readelf -x .callgraph - | FileCheck %s | ||
|
|
||
| declare !type !0 void @foo() | ||
|
|
||
| declare !type !1 i32 @bar(i8) | ||
|
|
||
| declare !type !2 ptr @baz(ptr) | ||
|
|
||
| define void @main() { | ||
| entry: | ||
| %a = alloca i8, align 1 | ||
| %fp_foo_val = load ptr, ptr null, align 8 | ||
| call void (...) %fp_foo_val(), !callee_type !1 | ||
| %fp_bar_val = load ptr, ptr null, align 8 | ||
| %param = trunc i64 0 to i8 | ||
| %call_fp_bar = call i32 %fp_bar_val(i8 signext %param), !callee_type !3 | ||
| %fp_baz_val = load ptr, ptr null, align 8 | ||
| %call_fp_baz = call ptr %fp_baz_val(ptr %a), !callee_type !4 | ||
| ret void | ||
| } | ||
|
|
||
| ;; 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': | ||
|
|
||
| ; CHECK-DAG: 2444f731 f5eecb3e | ||
| !0 = !{i64 0, !"_ZTSFvE.generalized"} | ||
| !1 = !{!0} | ||
| ; CHECK-DAG: 5486bc59 814b8e30 | ||
Prabhuk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| !2 = !{i64 0, !"_ZTSFicE.generalized"} | ||
| !3 = !{!2} | ||
Prabhuk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ; CHECK-DAG: 7ade6814 f897fd77 | ||
| !4 = !{!5} | ||
| !5 = !{i64 0, !"_ZTSFPvS_E.generalized"} | ||
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.