Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[llvm] Introduce callee_type metadata #87573

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
wants to merge 29 commits into
base: users/Prabhuk/sprmain.clangcallgraphsection-add-type-id-metadata-to-indirect-call-and-targets
Choose a base branch
Loading
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3565040
[𝘀𝗽𝗿] initial version
necipfazil Apr 3, 2024
a8a5848
Update clang/lib/CodeGen/CodeGenModule.cpp
Prabhuk Apr 22, 2024
019b2ca
Update clang/lib/CodeGen/CodeGenModule.cpp
Prabhuk Apr 22, 2024
15d0727
Refactored calls to emit type id metadata to be within EmitCall funct…
Prabhuk Apr 24, 2024
feef77b
Rebased on top of main
Prabhuk Apr 24, 2024
9924290
dyn_cast to isa
Prabhuk Apr 29, 2024
76244d9
Addressed review comments and a FIXME. Rebased on upstream main.
Prabhuk May 1, 2024
179f930
Rebase patchset
necipfazil Nov 14, 2024
e31af7b
Update inline comment as suggested.
necipfazil Nov 14, 2024
a3ca3e2
Rebase on top of upstream main.
necipfazil Nov 20, 2024
9c94f5e
Break clang and llvm parts into separate commits.
Prabhuk Nov 20, 2024
24882b1
Address review comments. Break llvm and clang patches.
Prabhuk Dec 10, 2024
4041391
Address maybe unused comment
Prabhuk Feb 2, 2025
1942c70
Rebase on top of main.
Prabhuk Feb 2, 2025
995729b
Rename OB_type to OB_callee_type.
Prabhuk Feb 5, 2025
c202534
Rebase on top of main
Prabhuk Feb 11, 2025
10c0327
Address review comments on the test file.
Prabhuk Mar 19, 2025
27c970a
Remove callee_type operand bundle.
Prabhuk Apr 19, 2025
83c95a1
Handle instcombine usecase for callee_type metadata.
Prabhuk Apr 23, 2025
fdf6a1c
Verifier changes.
Prabhuk Apr 23, 2025
4b32ce1
Update the test.
Prabhuk Apr 23, 2025
11404d7
Add verifier test.
Prabhuk Apr 24, 2025
193551b
Add inliner test. Fix instcombine test.
Prabhuk Apr 28, 2025
3c99824
Update tests. Rebase on top of main.
Prabhuk May 1, 2025
018bc97
Remove direct call check from Verifier.
Prabhuk May 5, 2025
55c721b
Updated langref.
Prabhuk May 10, 2025
acdc10d
Update documentation.
Prabhuk May 14, 2025
bb3ae95
Fix doc typo.
Prabhuk May 14, 2025
4dee1b9
Address comments on changes to tests.
Prabhuk May 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add verifier test.
Created using spr 1.3.6-beta.1
  • Loading branch information
Prabhuk committed Apr 24, 2025
commit 11404d726fb5e64aed895e3a1ac23d8780c88d5f
5 changes: 4 additions & 1 deletion 5 llvm/lib/IR/Verifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5059,9 +5059,12 @@ void Verifier::visitCalleeTypeMetadata(Instruction &I, MDNode *MD) {
"!callee_type metadata should only exist on indirect function calls",
&I);
Prabhuk marked this conversation as resolved.
Show resolved Hide resolved
for (const auto &Op : MD->operands()) {
Prabhuk marked this conversation as resolved.
Show resolved Hide resolved
Check(isa<MDNode>(Op.get()),
"The callee_type metadata must be a list of type metadata nodes");
auto *TypeMD = cast<MDNode>(Op.get());
Check(TypeMD->hasGeneralizedMDString(),
"Invalid \"callee_type\" type identifier", &I);
"Only generalized type metadata can be part of the callee_type "
"metadata list");
}
}

Expand Down
28 changes: 28 additions & 0 deletions 28 llvm/test/Verifier/callee-type-metadata.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
;; Test if the callee_type metadata attached to indirect call sites adhere to the expected format.

; RUN: not opt -passes=verify < %s 2>&1 | FileCheck %s
Prabhuk marked this conversation as resolved.
Show resolved Hide resolved
define i32 @_Z13call_indirectPFicEc(ptr %func, i8 signext %x) !type !0 {
entry:
%func.addr = alloca ptr, align 8
%x.addr = alloca i8, align 1
store ptr %func, ptr %func.addr, align 8
store i8 %x, ptr %x.addr, align 1
%fptr = load ptr, ptr %func.addr, align 8
%fptr_val = load i8, ptr %x.addr, align 1
;; No failures expected for this callee_type metdata.
%call = call i32 %fptr(i8 signext %fptr_val), !callee_type !1
;; callee_type metdata is a type metadata instead of a list of type metadata nodes.
; CHECK: The callee_type metadata must be a list of type metadata nodes
%call2 = call i32 %fptr(i8 signext %fptr_val), !callee_type !0
;; callee_type metdata is a list of non "gneralized" type metadata.
; CHECK: Only generalized type metadata can be part of the callee_type metadata list
%call3 = call i32 %fptr(i8 signext %fptr_val), !callee_type !4
ret i32 %call
}

!0 = !{i64 0, !"_ZTSFiPvcE.generalized"}
!1 = !{!2}
!2 = !{i64 0, !"_ZTSFicE.generalized"}
!3 = !{i64 0, !"_ZTSFicE"}
!4 = !{!3}
; CHECK-NEXT: error: input module is broken!
Morty Proxy This is a proxified and sanitized view of the page, visit original site.