-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[llvm] Extract and propagate callee_type metadata #87575
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 96 commits into
main
from
users/Prabhuk/sprcallsiteinfocallgraphsection-extract-and-propagate-indirect-call-type-ids
Jul 30, 2025
Merged
Changes from all commits
Commits
Show all changes
96 commits
Select commit
Hold shift + click to select a range
d2d56f4
[𝘀𝗽𝗿] changes to main this commit is based on
necipfazil f805007
[𝘀𝗽𝗿] initial version
necipfazil 058a100
[𝘀𝗽𝗿] changes introduced through rebase
necipfazil 2a17e59
Rebased on top of main
necipfazil 3065b9b
[𝘀𝗽𝗿] changes introduced through rebase
necipfazil a998707
dyn_cast to isa
necipfazil c2f27b3
[𝘀𝗽𝗿] changes introduced through rebase
necipfazil 4a36a0c
Rebased on upstream main.
necipfazil 58e5ecf
[𝘀𝗽𝗿] changes introduced through rebase
necipfazil 851f62e
Rebase patchset
necipfazil 966ac5a
[𝘀𝗽𝗿] changes introduced through rebase
necipfazil 460f02a
Update inline comment as suggested.
necipfazil 1a8d810
Fixed the tests and addressed most of the review comments.
necipfazil a993e6d
[𝘀𝗽𝗿] changes introduced through rebase
necipfazil 4f31680
Rebase on top of upstream main. Remove opt has_value, value use.
necipfazil bb9d714
[𝘀𝗽𝗿] changes introduced through rebase
necipfazil 086baf0
Break clang and llvm parts into separate commits.
necipfazil 746e03c
[𝘀𝗽𝗿] changes introduced through rebase
necipfazil 5d09cf0
Address review comments. Break llvm and clang patches.
necipfazil 67662e4
[𝘀𝗽𝗿] changes introduced through rebase
necipfazil f38ce99
Rebase on top of main.
necipfazil cfcb9c4
[𝘀𝗽𝗿] changes introduced through rebase
necipfazil f80a182
Rename OB_type to OB_callee_type.
necipfazil 8c18c46
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk fe1b3e2
Rebase on top of main
necipfazil 80f879e
Update IR verifier.
necipfazil f769ce6
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 162e967
Add requested tests part 1.
necipfazil 647db9a
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk ddc8de5
Update comments in tests.
necipfazil 5e97695
Remove unnecessary asserts. Remove autos for better readability.
necipfazil 1429f1d
Add RISC-V support. Clean up test files.
necipfazil 306e08b
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 061fd55
Clean up test files.
necipfazil 9a63148
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 09a933d
Address code refactoring and test cleanup comments.
Prabhuk 4a45618
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk f1be618
Use metadata instead of OB to construct CallSiteInfo.
Prabhuk 3eee130
Address review comments.
Prabhuk 9ceb54c
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 55ea3e2
Add tailcall tests.
Prabhuk 175b5f1
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 4724c6e
Move verifier down to parent change.
Prabhuk 721cb8b
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk f6a71b5
Address review comments.
Prabhuk 7a32b7e
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk a55c857
Address review comments.
Prabhuk 484ad23
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 5e5690a
Rebase on parent.
Prabhuk 11b6b2f
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk baaa763
Rebase on parent.
Prabhuk dd2c0b8
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 6c0b729
Rebase on parent.
Prabhuk b813c25
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 5d49a8d
Rebase on parent.
Prabhuk 35ef409
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 706478e
Rebase on parent.
Prabhuk 07b7f6c
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk dd7e4b4
Rebase on parent change.
Prabhuk d7e6843
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk a388287
Remove dso_local and noundef from tests.
Prabhuk 29cc917
Test direct call sites.
Prabhuk 7e133e5
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 00d17d1
Rebase change stack on top of parent.
Prabhuk 5ec5e7a
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 195cd6e
Rebase on main.
Prabhuk f1154ce
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 70ca198
Drop local_unnamed_addr.
Prabhuk 24fd769
Replace not check with positive checks.
Prabhuk b8f1934
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 5431cd5
Rebase.
Prabhuk 37faf58
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 38ac87a
Rebase on parent
Prabhuk 975676e
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk a7ac510
Rebase on top of main.
Prabhuk 9c96517
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 3f9848f
Rebase on top of main.
Prabhuk 3c53c18
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 72f6773
Rebase on parent
Prabhuk 11dc6bf
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 34eb039
Rebase on top of parent change.
Prabhuk ac406a5
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk fd7299f
Rebase on parent.
Prabhuk 67756fc
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 2065a88
Rebase on parent.
Prabhuk 37e8d19
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 44d4463
Address review comments.
Prabhuk 690ff13
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 3ec7216
Rebase on top of main.
Prabhuk de6003d
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk 0e2eb95
Rebase.
Prabhuk 4f76066
[𝘀𝗽𝗿] changes introduced through rebase
Prabhuk faf9f8f
Reduce tests. Update comments in tests. Rename functions in tests.
Prabhuk 7b846f0
Rebase on main.
Prabhuk 858480f
Change test var name.
Prabhuk 230e666
Rebase after reapplying parent patch.
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
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
32 changes: 32 additions & 0 deletions
32
llvm/test/CodeGen/AArch64/calleetypeid-directcall-mismatched.ll
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,32 @@ | ||
;; Tests that callee_type metadata attached to direct call sites are safely ignored. | ||
|
||
; RUN: llc --call-graph-section -mtriple aarch64-linux-gnu < %s -stop-after=finalize-isel -o - | FileCheck --match-full-lines %s | ||
|
||
;; Test that `calleeTypeIds` field is not present in `callSites` | ||
; CHECK-LABEL: callSites: | ||
; CHECK-NEXT: - { bb: {{[0-9]+}}, offset: {{[0-9]+}}, fwdArgRegs: [] } | ||
; CHECK-NEXT: - { bb: {{[0-9]+}}, offset: {{[0-9]+}}, fwdArgRegs: [] } | ||
; CHECK-NEXT: - { bb: {{[0-9]+}}, offset: {{[0-9]+}}, fwdArgRegs: [] } | ||
define i32 @foo(i32 %x, i32 %y) !type !0 { | ||
entry: | ||
;; Call instruction with accurate callee_type. | ||
;; callee_type should be dropped seemlessly. | ||
%call = call i32 @fizz(i32 %x, i32 %y), !callee_type !1 | ||
;; Call instruction with mismatched callee_type. | ||
;; callee_type should be dropped seemlessly without errors. | ||
%call1 = call i32 @fizz(i32 %x, i32 %y), !callee_type !3 | ||
%add = add nsw i32 %call, %call1 | ||
;; Call instruction with mismatched callee_type. | ||
;; callee_type should be dropped seemlessly without errors. | ||
%call2 = call i32 @fizz(i32 %add, i32 %y), !callee_type !3 | ||
%sub = sub nsw i32 %add, %call2 | ||
ret i32 %sub | ||
} | ||
|
||
declare !type !2 i32 @fizz(i32, i32) | ||
|
||
!0 = !{i64 0, !"_ZTSFiiiiE.generalized"} | ||
!1 = !{!2} | ||
!2 = !{i64 0, !"_ZTSFiiiE.generalized"} | ||
!3 = !{!4} | ||
!4 = !{i64 0, !"_ZTSFicE.generalized"} |
19 changes: 19 additions & 0 deletions
19
llvm/test/CodeGen/AArch64/callsite-emit-calleetypeid-tailcall.ll
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,19 @@ | ||
;; Tests that call site callee type ids can be extracted and set from | ||
;; callee_type metadata for indirect tail calls. | ||
|
||
;; Verify the exact calleeTypeId value to ensure it is not garbage but the value | ||
;; computed as the type id from the callee_type metadata. | ||
; RUN: llc --call-graph-section -mtriple aarch64-linux-gnu < %s -stop-after=finalize-isel -o - | FileCheck --match-full-lines %s | ||
|
||
define i32 @check_tailcall(ptr %func, i8 %x) !type !0 { | ||
entry: | ||
; CHECK: callSites: | ||
; CHECK-NEXT: - { bb: {{.*}}, offset: {{.*}}, fwdArgRegs: [], calleeTypeIds: | ||
; CHECK-NEXT: [ 3498816979441845844 ] } | ||
%call = tail call i32 %func(i8 signext %x), !callee_type !1 | ||
ret i32 %call | ||
} | ||
|
||
Prabhuk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
!0 = !{i64 0, !"_ZTSFiPvcE.generalized"} | ||
!1 = !{!2} | ||
!2 = !{i64 0, !"_ZTSFicE.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,20 @@ | ||
;; Tests that call site callee type ids can be extracted and set from | ||
;; callee_type metadata. | ||
|
||
;; Verify the exact calleeTypeIds value to ensure it is not garbage but the value | ||
;; computed as the type id from the callee_type metadata. | ||
; RUN: llc --call-graph-section -mtriple aarch64-linux-gnu < %s -stop-after=finalize-isel -o - | FileCheck --match-full-lines %s | ||
|
||
; CHECK: name: main | ||
; CHECK: callSites: | ||
; CHECK-NEXT: - { bb: {{.*}}, offset: {{.*}}, fwdArgRegs: [], calleeTypeIds: | ||
; CHECK-NEXT: [ 7854600665770582568 ] } | ||
define i32 @main() { | ||
entry: | ||
%fn = load ptr, ptr null, align 8 | ||
call void %fn(i8 0), !callee_type !0 | ||
ret i32 0 | ||
} | ||
|
||
!0 = !{!1} | ||
!1 = !{i64 0, !"_ZTSFvcE.generalized"} |
32 changes: 32 additions & 0 deletions
32
llvm/test/CodeGen/ARM/calleetypeid-directcall-mismatched.ll
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,32 @@ | ||
;; Tests that callee_type metadata attached to direct call sites are safely ignored. | ||
|
||
; RUN: llc --call-graph-section -mtriple arm-linux-gnu < %s -stop-after=finalize-isel -o - | FileCheck --match-full-lines %s | ||
|
||
;; Test that `calleeTypeIds` field is not present in `callSites` | ||
; CHECK-LABEL: callSites: | ||
; CHECK-NEXT: - { bb: {{[0-9]+}}, offset: {{[0-9]+}}, fwdArgRegs: [] } | ||
; CHECK-NEXT: - { bb: {{[0-9]+}}, offset: {{[0-9]+}}, fwdArgRegs: [] } | ||
; CHECK-NEXT: - { bb: {{[0-9]+}}, offset: {{[0-9]+}}, fwdArgRegs: [] } | ||
define i32 @foo(i32 %x, i32 %y) !type !0 { | ||
entry: | ||
;; Call instruction with accurate callee_type. | ||
;; callee_type should be dropped seemlessly. | ||
%call = call i32 @fizz(i32 %x, i32 %y), !callee_type !1 | ||
;; Call instruction with mismatched callee_type. | ||
;; callee_type should be dropped seemlessly without errors. | ||
%call1 = call i32 @fizz(i32 %x, i32 %y), !callee_type !3 | ||
%add = add nsw i32 %call, %call1 | ||
;; Call instruction with mismatched callee_type. | ||
;; callee_type should be dropped seemlessly without errors. | ||
%call2 = call i32 @fizz(i32 %add, i32 %y), !callee_type !3 | ||
%sub = sub nsw i32 %add, %call2 | ||
ret i32 %sub | ||
} | ||
|
||
declare !type !2 i32 @fizz(i32, i32) | ||
|
||
!0 = !{i64 0, !"_ZTSFiiiiE.generalized"} | ||
!1 = !{!2} | ||
!2 = !{i64 0, !"_ZTSFiiiE.generalized"} | ||
!3 = !{!4} | ||
!4 = !{i64 0, !"_ZTSFicE.generalized"} |
19 changes: 19 additions & 0 deletions
19
llvm/test/CodeGen/ARM/callsite-emit-calleetypeid-tailcall.ll
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,19 @@ | ||
;; Tests that call site callee type ids can be extracted and set from | ||
;; callee_type metadata for indirect tail calls. | ||
|
||
;; Verify the exact calleeTypeId value to ensure it is not garbage but the value | ||
;; computed as the type id from the callee_type metadata. | ||
; RUN: llc --call-graph-section -mtriple arm-linux-gnu < %s -stop-after=finalize-isel -o - | FileCheck --match-full-lines %s | ||
|
||
define i32 @check_tailcall(ptr %func, i8 %x) !type !0 { | ||
entry: | ||
; CHECK: callSites: | ||
; CHECK-NEXT: - { bb: {{.*}}, offset: {{.*}}, fwdArgRegs: [], calleeTypeIds: | ||
; CHECK-NEXT: [ 3498816979441845844 ] } | ||
%call = tail call i32 %func(i8 signext %x), !callee_type !1 | ||
ret i32 %call | ||
} | ||
|
||
!0 = !{i64 0, !"_ZTSFiPvcE.generalized"} | ||
!1 = !{!2} | ||
!2 = !{i64 0, !"_ZTSFicE.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,20 @@ | ||
;; Tests that call site callee type ids can be extracted and set from | ||
;; callee_type metadata. | ||
|
||
;; Verify the exact calleeTypeIds value to ensure it is not garbage but the value | ||
;; computed as the type id from the callee_type metadata. | ||
; RUN: llc --call-graph-section -mtriple arm-linux-gnu < %s -stop-after=finalize-isel -o - | FileCheck --match-full-lines %s | ||
|
||
; CHECK: name: main | ||
; CHECK: callSites: | ||
; CHECK-NEXT: - { bb: {{.*}}, offset: {{.*}}, fwdArgRegs: [], calleeTypeIds: | ||
; CHECK-NEXT: [ 7854600665770582568 ] } | ||
define i32 @main() { | ||
entry: | ||
%fn = load ptr, ptr null, align 8 | ||
call void %fn(i8 0), !callee_type !0 | ||
ret i32 0 | ||
} | ||
|
||
!0 = !{!1} | ||
!1 = !{i64 0, !"_ZTSFvcE.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.