-
Notifications
You must be signed in to change notification settings - Fork 14.5k
[IR2Vec] Add embeddings mode to llvm-ir2vec tool #147844
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
svkeerthy
merged 1 commit into
main
from
users/svkeerthy/07-09-ir2vec_tool_enhancements
Jul 17, 2025
+260
−16
Merged
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
; RUN: llvm-ir2vec --mode=embeddings --ir2vec-vocab-path=%ir2vec_test_vocab_dir/dummy_3D_nonzero_opc_vocab.json %s | FileCheck %s -check-prefix=CHECK-DEFAULT | ||
; RUN: llvm-ir2vec --mode=embeddings --level=func --ir2vec-vocab-path=%ir2vec_test_vocab_dir/dummy_3D_nonzero_opc_vocab.json %s | FileCheck %s -check-prefix=CHECK-FUNC-LEVEL | ||
; RUN: llvm-ir2vec --mode=embeddings --level=func --function=abc --ir2vec-vocab-path=%ir2vec_test_vocab_dir/dummy_3D_nonzero_opc_vocab.json %s | FileCheck %s -check-prefix=CHECK-FUNC-LEVEL-ABC | ||
; RUN: not llvm-ir2vec --mode=embeddings --level=func --function=def --ir2vec-vocab-path=%ir2vec_test_vocab_dir/dummy_3D_nonzero_opc_vocab.json %s 2>&1 | FileCheck %s -check-prefix=CHECK-FUNC-DEF | ||
; RUN: llvm-ir2vec --mode=embeddings --level=bb --ir2vec-vocab-path=%ir2vec_test_vocab_dir/dummy_3D_nonzero_opc_vocab.json %s | FileCheck %s -check-prefix=CHECK-BB-LEVEL | ||
; RUN: llvm-ir2vec --mode=embeddings --level=bb --function=abc_repeat --ir2vec-vocab-path=%ir2vec_test_vocab_dir/dummy_3D_nonzero_opc_vocab.json %s | FileCheck %s -check-prefix=CHECK-BB-LEVEL-ABC-REPEAT | ||
; RUN: llvm-ir2vec --mode=embeddings --level=inst --function=abc_repeat --ir2vec-vocab-path=%ir2vec_test_vocab_dir/dummy_3D_nonzero_opc_vocab.json %s | FileCheck %s -check-prefix=CHECK-INST-LEVEL-ABC-REPEAT | ||
|
||
define dso_local noundef float @abc(i32 noundef %a, float noundef %b) #0 { | ||
entry: | ||
%a.addr = alloca i32, align 4 | ||
%b.addr = alloca float, align 4 | ||
store i32 %a, ptr %a.addr, align 4 | ||
store float %b, ptr %b.addr, align 4 | ||
%0 = load i32, ptr %a.addr, align 4 | ||
%1 = load i32, ptr %a.addr, align 4 | ||
%mul = mul nsw i32 %0, %1 | ||
%conv = sitofp i32 %mul to float | ||
%2 = load float, ptr %b.addr, align 4 | ||
%add = fadd float %conv, %2 | ||
ret float %add | ||
} | ||
|
||
define dso_local noundef float @abc_repeat(i32 noundef %a, float noundef %b) #0 { | ||
entry: | ||
%a.addr = alloca i32, align 4 | ||
%b.addr = alloca float, align 4 | ||
store i32 %a, ptr %a.addr, align 4 | ||
store float %b, ptr %b.addr, align 4 | ||
%0 = load i32, ptr %a.addr, align 4 | ||
%1 = load i32, ptr %a.addr, align 4 | ||
%mul = mul nsw i32 %0, %1 | ||
%conv = sitofp i32 %mul to float | ||
%2 = load float, ptr %b.addr, align 4 | ||
%add = fadd float %conv, %2 | ||
ret float %add | ||
} | ||
|
||
; CHECK-DEFAULT: Function: abc | ||
; CHECK-DEFAULT-NEXT: [ 878.00 889.00 900.00 ] | ||
; CHECK-DEFAULT-NEXT: Function: abc_repeat | ||
; CHECK-DEFAULT-NEXT: [ 878.00 889.00 900.00 ] | ||
|
||
; CHECK-FUNC-LEVEL: Function: abc | ||
; CHECK-FUNC-LEVEL-NEXT: [ 878.00 889.00 900.00 ] | ||
; CHECK-FUNC-LEVEL-NEXT: Function: abc_repeat | ||
; CHECK-FUNC-LEVEL-NEXT: [ 878.00 889.00 900.00 ] | ||
|
||
; CHECK-FUNC-LEVEL-ABC: Function: abc | ||
; CHECK-FUNC-LEVEL-NEXT-ABC: [ 878.00 889.00 900.00 ] | ||
|
||
; CHECK-FUNC-DEF: Error: Function 'def' not found | ||
|
||
; CHECK-BB-LEVEL: Function: abc | ||
; CHECK-BB-LEVEL-NEXT: entry: [ 878.00 889.00 900.00 ] | ||
; CHECK-BB-LEVEL-NEXT: Function: abc_repeat | ||
; CHECK-BB-LEVEL-NEXT: entry: [ 878.00 889.00 900.00 ] | ||
|
||
; CHECK-BB-LEVEL-ABC-REPEAT: Function: abc_repeat | ||
; CHECK-BB-LEVEL-ABC-REPEAT-NEXT: entry: [ 878.00 889.00 900.00 ] | ||
|
||
; CHECK-INST-LEVEL-ABC-REPEAT: Function: abc_repeat | ||
; CHECK-INST-LEVEL-ABC-REPEAT-NEXT: %a.addr = alloca i32, align 4 [ 91.00 92.00 93.00 ] | ||
; CHECK-INST-LEVEL-ABC-REPEAT-NEXT: %b.addr = alloca float, align 4 [ 91.00 92.00 93.00 ] | ||
; CHECK-INST-LEVEL-ABC-REPEAT-NEXT: store i32 %a, ptr %a.addr, align 4 [ 97.00 98.00 99.00 ] | ||
; CHECK-INST-LEVEL-ABC-REPEAT-NEXT: store float %b, ptr %b.addr, align 4 [ 97.00 98.00 99.00 ] | ||
; CHECK-INST-LEVEL-ABC-REPEAT-NEXT: %0 = load i32, ptr %a.addr, align 4 [ 94.00 95.00 96.00 ] | ||
; CHECK-INST-LEVEL-ABC-REPEAT-NEXT: %1 = load i32, ptr %a.addr, align 4 [ 94.00 95.00 96.00 ] | ||
; CHECK-INST-LEVEL-ABC-REPEAT-NEXT: %mul = mul nsw i32 %0, %1 [ 49.00 50.00 51.00 ] | ||
; CHECK-INST-LEVEL-ABC-REPEAT-NEXT: %conv = sitofp i32 %mul to float [ 130.00 131.00 132.00 ] | ||
; CHECK-INST-LEVEL-ABC-REPEAT-NEXT: %2 = load float, ptr %b.addr, align 4 [ 94.00 95.00 96.00 ] | ||
; CHECK-INST-LEVEL-ABC-REPEAT-NEXT: %add = fadd float %conv, %2 [ 40.00 41.00 42.00 ] | ||
; CHECK-INST-LEVEL-ABC-REPEAT-NEXT: ret float %add [ 1.00 2.00 3.00 ] |
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
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.
Does
clang-format
not let you indent here?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.
Wierdly yes!