-
Notifications
You must be signed in to change notification settings - Fork 14.6k
[IR2Vec][llvm-ir2vec] Revamp triplet generation and add entity mapping mode #149214
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
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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,95 @@ | ||
; RUN: llvm-ir2vec --mode=entities | FileCheck %s | ||
|
||
CHECK: 92 | ||
CHECK-NEXT: Ret 0 | ||
CHECK-NEXT: Br 1 | ||
CHECK-NEXT: Switch 2 | ||
CHECK-NEXT: IndirectBr 3 | ||
CHECK-NEXT: Invoke 4 | ||
CHECK-NEXT: Resume 5 | ||
CHECK-NEXT: Unreachable 6 | ||
CHECK-NEXT: CleanupRet 7 | ||
CHECK-NEXT: CatchRet 8 | ||
CHECK-NEXT: CatchSwitch 9 | ||
CHECK-NEXT: CallBr 10 | ||
CHECK-NEXT: FNeg 11 | ||
CHECK-NEXT: Add 12 | ||
CHECK-NEXT: FAdd 13 | ||
CHECK-NEXT: Sub 14 | ||
CHECK-NEXT: FSub 15 | ||
CHECK-NEXT: Mul 16 | ||
CHECK-NEXT: FMul 17 | ||
CHECK-NEXT: UDiv 18 | ||
CHECK-NEXT: SDiv 19 | ||
CHECK-NEXT: FDiv 20 | ||
CHECK-NEXT: URem 21 | ||
CHECK-NEXT: SRem 22 | ||
CHECK-NEXT: FRem 23 | ||
CHECK-NEXT: Shl 24 | ||
CHECK-NEXT: LShr 25 | ||
CHECK-NEXT: AShr 26 | ||
CHECK-NEXT: And 27 | ||
CHECK-NEXT: Or 28 | ||
CHECK-NEXT: Xor 29 | ||
CHECK-NEXT: Alloca 30 | ||
CHECK-NEXT: Load 31 | ||
CHECK-NEXT: Store 32 | ||
CHECK-NEXT: GetElementPtr 33 | ||
CHECK-NEXT: Fence 34 | ||
CHECK-NEXT: AtomicCmpXchg 35 | ||
CHECK-NEXT: AtomicRMW 36 | ||
CHECK-NEXT: Trunc 37 | ||
CHECK-NEXT: ZExt 38 | ||
CHECK-NEXT: SExt 39 | ||
CHECK-NEXT: FPToUI 40 | ||
CHECK-NEXT: FPToSI 41 | ||
CHECK-NEXT: UIToFP 42 | ||
CHECK-NEXT: SIToFP 43 | ||
CHECK-NEXT: FPTrunc 44 | ||
CHECK-NEXT: FPExt 45 | ||
CHECK-NEXT: PtrToInt 46 | ||
CHECK-NEXT: IntToPtr 47 | ||
CHECK-NEXT: BitCast 48 | ||
CHECK-NEXT: AddrSpaceCast 49 | ||
CHECK-NEXT: CleanupPad 50 | ||
CHECK-NEXT: CatchPad 51 | ||
CHECK-NEXT: ICmp 52 | ||
CHECK-NEXT: FCmp 53 | ||
CHECK-NEXT: PHI 54 | ||
CHECK-NEXT: Call 55 | ||
CHECK-NEXT: Select 56 | ||
CHECK-NEXT: UserOp1 57 | ||
CHECK-NEXT: UserOp2 58 | ||
CHECK-NEXT: VAArg 59 | ||
CHECK-NEXT: ExtractElement 60 | ||
CHECK-NEXT: InsertElement 61 | ||
CHECK-NEXT: ShuffleVector 62 | ||
CHECK-NEXT: ExtractValue 63 | ||
CHECK-NEXT: InsertValue 64 | ||
CHECK-NEXT: LandingPad 65 | ||
CHECK-NEXT: Freeze 66 | ||
CHECK-NEXT: FloatTy 67 | ||
CHECK-NEXT: FloatTy 68 | ||
CHECK-NEXT: FloatTy 69 | ||
CHECK-NEXT: FloatTy 70 | ||
CHECK-NEXT: FloatTy 71 | ||
CHECK-NEXT: FloatTy 72 | ||
CHECK-NEXT: FloatTy 73 | ||
CHECK-NEXT: VoidTy 74 | ||
CHECK-NEXT: LabelTy 75 | ||
CHECK-NEXT: MetadataTy 76 | ||
CHECK-NEXT: UnknownTy 77 | ||
CHECK-NEXT: TokenTy 78 | ||
CHECK-NEXT: IntegerTy 79 | ||
CHECK-NEXT: FunctionTy 80 | ||
CHECK-NEXT: PointerTy 81 | ||
CHECK-NEXT: StructTy 82 | ||
CHECK-NEXT: ArrayTy 83 | ||
CHECK-NEXT: VectorTy 84 | ||
CHECK-NEXT: VectorTy 85 | ||
CHECK-NEXT: PointerTy 86 | ||
CHECK-NEXT: UnknownTy 87 | ||
CHECK-NEXT: Function 88 | ||
CHECK-NEXT: Pointer 89 | ||
CHECK-NEXT: Constant 90 | ||
CHECK-NEXT: Variable 91 |
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,22 @@ | ||
; Test error handling and input validation for llvm-ir2vec tool | ||
|
||
; RUN: not llvm-ir2vec --mode=embeddings %s 2>&1 | FileCheck %s -check-prefix=CHECK-NO-VOCAB | ||
|
||
; RUN: not llvm-ir2vec --mode=embeddings --function=nonexistent --ir2vec-vocab-path=%ir2vec_test_vocab_dir/dummy_3D_nonzero_opc_vocab.json %s 2>&1 | FileCheck %s -check-prefix=CHECK-FUNC-NOT-FOUND | ||
|
||
; RUN: llvm-ir2vec --mode=triplets --ir2vec-vocab-path=%ir2vec_test_vocab_dir/dummy_3D_nonzero_opc_vocab.json --level=inst %s 2>&1 | FileCheck %s -check-prefix=CHECK-UNUSED-LEVEL | ||
; RUN: llvm-ir2vec --mode=entities --level=inst %s 2>&1 | FileCheck %s -check-prefix=CHECK-UNUSED-LEVEL | ||
|
||
; RUN: llvm-ir2vec --mode=triplets --ir2vec-vocab-path=%ir2vec_test_vocab_dir/dummy_3D_nonzero_opc_vocab.json --function=dummy %s 2>&1 | FileCheck %s -check-prefix=CHECK-UNUSED-FUNC | ||
; RUN: llvm-ir2vec --mode=entities --function=dummy %s 2>&1 | FileCheck %s -check-prefix=CHECK-UNUSED-FUNC | ||
|
||
; Simple test function for valid IR | ||
define i32 @test_func(i32 %a) { | ||
entry: | ||
ret i32 %a | ||
} | ||
|
||
; CHECK-NO-VOCAB: error: IR2Vec vocabulary file path not specified; You may need to set it using --ir2vec-vocab-path | ||
; CHECK-FUNC-NOT-FOUND: Error: Function 'nonexistent' not found | ||
; CHECK-UNUSED-LEVEL: Warning: --level option is ignored | ||
; CHECK-UNUSED-FUNC: Warning: --function option is ignored |
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
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.
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.
you could also have dumped the expected output to a reference file under
Inputs
anddiff
.But I wouldn't bother doing that now, it's just more work, and my point was that there's a "less work" alternative - for next time.
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.
Yeah, got it.