LLVM: include/llvm/Analysis/IRSimilarityIdentifier.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49#ifndef LLVM_ANALYSIS_IRSIMILARITYIDENTIFIER_H
50#define LLVM_ANALYSIS_IRSIMILARITYIDENTIFIER_H
51
58#include
59
60namespace llvm {
61
63
65
66
67
68
69
70
71
72
73
74
75
76
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
116 : ilist_node<IRInstructionData, ilist_sentinel_tracking> {
117
118
120
122
123
124
125
127
128
129
130
132
133
134
135
136
137
138
139
140
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
166
167
168
169
170
171
175
176
177
179
180
181
183
184
185
187
188
189
190
191
192
194
195
196
197
198
199
200
201
204
205
206
207
208
209
210
211
212
213
214
215
216
217
219
220
221
222
223
224
225
226
229
230
231
232
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
264 for (Value *V : ID.OperVals)
265 OperTypes.push_back(V->getType());
266
272
274
275
276
283 }
284
286 std::string FunctionName = *ID.CalleeName;
292 }
293
297 }
298
300};
301
303 : simple_ilist<IRInstructionData, ilist_sentinel_tracking> {};
304
305
306
307
308
309
310
311
312
313
315
321
324 assert(E && "IRInstructionData is a nullptr?");
326 }
327
333
334 assert(LHS && RHS && "nullptr should have been caught by getEmptyKey?");
336 }
337};
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
381
382
383
385
386
388
389
392
393
394
396
397
398
399
400
402
403
405
406
407
409
410
411
413
414
415
416
418
419
420
421
423
424
425
426
427
428
429
430
431
435
436
437
438
439
440
441
444
445
446
447
449
451
452
453
454
455
456
461
462
463
465 unsigned BBNumber = 0;
468 }
469
470
471
472
473
474
475
476
479 std::vector<IRInstructionData *> &InstrList,
480 std::vector &IntegerMapping);
481
482
483
484
485
486
487
488
491 std::vector &IntegerMappingForBB,
492 std::vector<IRInstructionData *> &InstrListForBB);
493
494
495
496
497
498
499
500
501
502
505 std::vector<IRInstructionData *> &InstrListForBB, bool End = false);
506
510
511
513 static_cast<unsigned>(-1));
515 static_cast<unsigned>(-2));
516
519 }
520
521
522
524 : public InstVisitor<InstructionClassification, InstrType> {
526
527
538
540
541
543
544
548
549
550
551
552
553
554 if (II.isAssumeLikeIntrinsic())
557 }
558
559
565 if ( && !IsIndirectCall)
567
568
569
570
571
572
580 }
581
583
585
588
589
590
592
593
594
596
597
598
600
601
602
604 };
605
606
608};
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
653private:
654
655 unsigned StartIdx = 0;
656
657
658 unsigned Len = 0;
659
660
662
663
665
666
667
668
669
671
673
674
676
677
679
680
681public:
682
683
684
685
689
690
691
692
693
696
697
698
699
700
703
704
705
706
707
708
709
710
711
717
719
720
722
723
725
726
727
729 };
730
731
732
733
735
736
738
739
741
742
744 };
745
746
747
748
749
750
751
752
753
756
757
758
759
760
761
762
763
764
765
768
769
770
771
772
773
774
775
776
777
778
779
780
781
783 const unsigned InstValA, const unsigned &InstValB,
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
824
825
826
827
828
829
830
831
834
835
836
837
838
839
840
841
842
843
844
845
846
847
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
894
895
902
903
904
909 if (BBSet.insert(BB).second)
911 }
912 }
913
914
915
916
917
918
919
920
921
924
925
927
928
930
931
932 unsigned getEndIdx() const { return StartIdx + Len - 1; }
933
934
936
938
939
941
943
944
946
948
949
951
952
953
954
955
957 assert(V != nullptr && "Value is a nullptr?");
959 if (VNIt == ValueToNumber.end())
960 return std::nullopt;
961 return VNIt->second;
962 }
963
964
965
966
967
968 std::optional<Value *> fromGVN(unsigned Num) {
970 if (VNIt == NumberToValue.end())
971 return std::nullopt;
972 assert(VNIt->second != nullptr && "Found value is a nullptr!");
973 return VNIt->second;
974 }
975
976
977
978
979
980
981
984 if (NCIt == NumberToCanonNum.end())
985 return std::nullopt;
986 return NCIt->second;
987 }
988
989
990
991
992
993
994
997 if (CNIt == CanonNumToNumber.end())
998 return std::nullopt;
999 return CNIt->second;
1000 }
1001
1002
1003
1004
1008
1012};
1013
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1044public:
1046 bool MatchIndirectCalls = true,
1047 bool MatchCallsWithName = false,
1048 bool MatchIntrinsics = true,
1049 bool MatchMustTailCalls = true)
1050 : Mapper(&InstDataAllocator, &InstDataListAllocator),
1051 EnableBranches(MatchBranches), EnableIndirectCalls(MatchIndirectCalls),
1052 EnableMatchingCallsByName(MatchCallsWithName),
1053 EnableIntrinsics(MatchIntrinsics),
1054 EnableMustTailCalls(MatchMustTailCalls) {}
1055
1056private:
1057
1058
1059
1060
1061
1062
1063 void populateMapper(Module &M, std::vector<IRInstructionData *> &InstrList,
1064 std::vector &IntegerMapping);
1065
1066
1067
1068
1069
1070
1071
1072 void populateMapper(ArrayRef<std::unique_ptr> &Modules,
1073 std::vector<IRInstructionData *> &InstrList,
1074 std::vector &IntegerMapping);
1075
1076
1077
1078
1079
1080
1081
1082 void findCandidates(std::vector<IRInstructionData *> &InstrList,
1083 std::vector &IntegerMapping);
1084
1085public:
1086
1087
1088
1089
1090
1091
1094
1095
1096
1097
1098
1099
1101
1102
1104
1105
1106
1107 if (SimilarityCandidates)
1108 SimilarityCandidates->clear();
1109 else
1111 }
1112
1113
1114
1116 return SimilarityCandidates;
1117 }
1118
1119private:
1120
1122
1123
1125
1126
1127
1129
1130
1131
1132 bool EnableBranches = true;
1133
1134
1135
1136 bool EnableIndirectCalls = true;
1137
1138
1139
1140
1141 bool EnableMatchingCallsByName = true;
1142
1143
1144
1145 bool EnableIntrinsics = true;
1146
1147
1148
1149 bool EnableMustTailCalls = false;
1150
1151
1152
1153 std::optional SimilarityCandidates;
1154};
1155
1156}
1157
1158
1159
1161 std::unique_ptrIRSimilarity::IRSimilarityIdentifier IRSI;
1162
1163public:
1166
1169
1170 bool doInitialization(Module &M) override;
1171 bool doFinalization(Module &M) override;
1172 bool runOnModule(Module &M) override;
1176};
1177
1178
1179
1181public:
1183
1185
1186private:
1189};
1190
1191
1193 : public PassInfoMixin {
1195
1196public:
1200};
1201
1202}
1203
1204#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the BumpPtrAllocator interface.
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This header defines various interfaces for pass management in LLVM.
uint64_t IntrinsicInst * II
an instruction to allocate memory on the stack
Represent the analysis usage information of a pass.
void setPreservesAll()
Set by analyses that do not transform their input at all.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
LLVM Basic Block Representation.
const Function * getParent() const
Return the enclosing method, or null if none.
InstListType::iterator iterator
Instruction iterators...
Conditional or Unconditional Branch instruction.
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
CallingConv::ID getCallingConv() const
LLVM_ABI bool isIndirectCall() const
Return true if the callsite is an indirect call.
CallBr instruction, tracking function calls that may not return control but instead transfer it to a ...
This class represents a function call, abstracting a target machine's calling convention.
bool isMustTailCall() const
This class is the base class for the comparison instructions.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
DenseMapIterator< KeyT, ValueT, KeyInfoT, BucketT > iterator
Implements a dense probed hash-table based set.
static bool isRequired()
Definition IRSimilarityIdentifier.h:1199
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
IRSimilarityAnalysisPrinterPass(raw_ostream &OS)
Definition IRSimilarityIdentifier.h:1197
An analysis pass that runs and returns the IRSimilarityIdentifier run on the Module.
Definition IRSimilarityIdentifier.h:1180
IRSimilarity::IRSimilarityIdentifier Result
Definition IRSimilarityIdentifier.h:1182
LLVM_ABI Result run(Module &M, ModuleAnalysisManager &)
IRSimilarityIdentifierWrapperPass()
IRSimilarity::IRSimilarityIdentifier & getIRSI()
Definition IRSimilarityIdentifier.h:1167
static char ID
Definition IRSimilarityIdentifier.h:1164
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Definition IRSimilarityIdentifier.h:1173
const IRSimilarity::IRSimilarityIdentifier & getIRSI() const
Definition IRSimilarityIdentifier.h:1168
This is a class that wraps a range of IRInstructionData from one point to another in the vector of IR...
Definition IRSimilarityIdentifier.h:652
Instruction * backInstruction()
Definition IRSimilarityIdentifier.h:942
LLVM_ABI void createCanonicalRelationFrom(IRSimilarityCandidate &SourceCand, DenseMap< unsigned, DenseSet< unsigned > > &ToSourceMapping, DenseMap< unsigned, DenseSet< unsigned > > &FromSourceMapping)
Create a mapping for the value numbering of the calling IRSimilarityCandidate, to a different separat...
static LLVM_ABI bool isSimilar(const IRSimilarityCandidate &A, const IRSimilarityCandidate &B)
LLVM_ABI void createCanonicalRelationFrom(IRSimilarityCandidate &SourceCand, DenseMap< unsigned, unsigned > &OneToOne, DenseMap< unsigned, DenseSet< unsigned > > &ToSourceMapping, DenseMap< unsigned, DenseSet< unsigned > > &FromSourceMapping)
Create a mapping for the value numbering of the calling IRSimilarityCandidate, to a different separat...
iterator end() const
Definition IRSimilarityIdentifier.h:1011
std::optional< unsigned > getGVN(Value *V)
Finds the positive number associated with V if it has been mapped.
Definition IRSimilarityIdentifier.h:956
unsigned getLength() const
Definition IRSimilarityIdentifier.h:926
void getBasicBlocks(DenseSet< BasicBlock * > &BBSet, SmallVector< BasicBlock * > &BBList) const
Definition IRSimilarityIdentifier.h:905
unsigned getEndIdx() const
Definition IRSimilarityIdentifier.h:932
static LLVM_ABI bool compareAssignmentMapping(const unsigned InstValA, const unsigned &InstValB, DenseMap< unsigned, DenseSet< unsigned > > &ValueNumberMappingA, DenseMap< unsigned, DenseSet< unsigned > > &ValueNumberMappingB)
Compare the GVN of the assignment value in corresponding instructions in IRSimilarityCandidates A and...
IRInstructionData * back() const
Definition IRSimilarityIdentifier.h:937
void getBasicBlocks(DenseSet< BasicBlock * > &BBSet) const
Definition IRSimilarityIdentifier.h:896
bool operator<(const IRSimilarityCandidate &RHS) const
Definition IRSimilarityIdentifier.h:1005
std::optional< Value * > fromGVN(unsigned Num)
Finds the Value associate with Num if it exists.
Definition IRSimilarityIdentifier.h:968
IRInstructionDataList::iterator iterator
Definition IRSimilarityIdentifier.h:1009
BasicBlock * getEndBB()
Definition IRSimilarityIdentifier.h:947
Instruction * frontInstruction()
Definition IRSimilarityIdentifier.h:940
static LLVM_ABI bool checkRelativeLocations(RelativeLocMapping A, RelativeLocMapping B)
Compare the relative locations in A and B and check that the distances match if both locations are co...
static LLVM_ABI bool compareStructure(const IRSimilarityCandidate &A, const IRSimilarityCandidate &B)
static LLVM_ABI void createCanonicalMappingFor(IRSimilarityCandidate &CurrCand)
Create a mapping from the value numbering to a different separate set of numbers.
Function * getFunction()
Definition IRSimilarityIdentifier.h:950
iterator begin() const
Definition IRSimilarityIdentifier.h:1010
static LLVM_ABI bool overlap(const IRSimilarityCandidate &A, const IRSimilarityCandidate &B)
Compare the start and end indices of the two IRSimilarityCandidates for whether they overlap.
unsigned getStartIdx() const
Definition IRSimilarityIdentifier.h:929
BasicBlock * getStartBB()
Definition IRSimilarityIdentifier.h:945
LLVM_ABI IRSimilarityCandidate(unsigned StartIdx, unsigned Len, IRInstructionData *FirstInstIt, IRInstructionData *LastInstIt)
std::optional< unsigned > getCanonicalNum(unsigned N)
Find the canonical number from the global value number N stored in the candidate.
Definition IRSimilarityIdentifier.h:982
std::optional< unsigned > fromCanonicalNum(unsigned N)
Find the global value number from the canonical number N stored in the candidate.
Definition IRSimilarityIdentifier.h:995
IRInstructionData * front() const
Definition IRSimilarityIdentifier.h:935
static LLVM_ABI bool compareNonCommutativeOperandMapping(OperandMapping A, OperandMapping B)
Compare the operands in A and B and check that the current mapping of global value numbers from A to ...
static LLVM_ABI bool compareCommutativeOperandMapping(OperandMapping A, OperandMapping B)
Compare the operands in A and B and check that the current mapping of global value numbers from A to ...
This class puts all the pieces of the IRInstructionData, IRInstructionMapper, IRSimilarityCandidate t...
Definition IRSimilarityIdentifier.h:1043
IRSimilarityIdentifier(bool MatchBranches=true, bool MatchIndirectCalls=true, bool MatchCallsWithName=false, bool MatchIntrinsics=true, bool MatchMustTailCalls=true)
Definition IRSimilarityIdentifier.h:1045
void resetSimilarityCandidates()
Definition IRSimilarityIdentifier.h:1103
LLVM_ABI SimilarityGroupList & findSimilarity(ArrayRef< std::unique_ptr< Module > > Modules)
std::optional< SimilarityGroupList > & getSimilarity()
Definition IRSimilarityIdentifier.h:1115
Base class for instruction visitors.
A wrapper class for inspecting calls to intrinsic functions.
The landingpad instruction holds all of the information necessary to generate correct exception handl...
A Module instance is used to store all the information related to an LLVM module.
A set of analyses that are preserved following a run of a transformation pass.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
A BumpPtrAllocator that allows only elements of a specific type to be allocated.
StringRef - Represent a constant reference to a string, i.e.
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
LLVM Value Representation.
std::pair< iterator, bool > insert(const ValueT &V)
An opaque object representing a hash code.
This class implements an extremely fast bulk output stream that can only output to a stream.
ilist_select_iterator_type< OptionsT, false, false > iterator
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ Tail
Attemps to make calls as fast as possible while guaranteeing that tail call optimization can always b...
@ SwiftTail
This follows the Swift calling convention in how arguments are passed but guarantees tail calls will ...
std::vector< SimilarityGroup > SimilarityGroupList
Definition IRSimilarityIdentifier.h:1018
std::vector< IRSimilarityCandidate > SimilarityGroup
Definition IRSimilarityIdentifier.h:1017
DenseMap< IRSimilarityCandidate *, DenseMap< unsigned, DenseSet< unsigned > > > CandidateGVNMapping
Definition IRSimilarityIdentifier.h:1016
LLVM_ABI bool isClose(const IRInstructionData &A, const IRInstructionData &B)
Compare one IRInstructionData class to another IRInstructionData class for whether they are performin...
InstrType
This represents what is and is not supported when finding similarity in Instructions.
Definition IRSimilarityIdentifier.h:77
@ Illegal
Definition IRSimilarityIdentifier.h:77
@ Invisible
Definition IRSimilarityIdentifier.h:77
@ Legal
Definition IRSimilarityIdentifier.h:77
This is an optimization pass for GlobalISel generic memory operations.
hash_code hash_value(const FixedPointSemantics &Val)
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
bool isa(const From &Val)
isa - Return true if the parameter to the template is an instance of one of the template type argu...
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
A CRTP mix-in that provides informational APIs needed for analysis passes.
A special type used by analysis passes to provide an address that identifies that particular analysis...
An information struct used to provide DenseMap with the various necessary components for a given valu...
static IRInstructionData * getEmptyKey()
Definition IRSimilarityIdentifier.h:317
static unsigned getHashValue(const IRInstructionData *E)
Definition IRSimilarityIdentifier.h:322
static bool isEqual(const IRInstructionData *LHS, const IRInstructionData *RHS)
Definition IRSimilarityIdentifier.h:328
static IRInstructionData * getTombstoneKey()
Definition IRSimilarityIdentifier.h:318
This provides the utilities for hashing an Instruction to an unsigned integer.
Definition IRSimilarityIdentifier.h:116
LLVM_ABI StringRef getCalleeName() const
Get the callee name that the call instruction is using for hashing the instruction.
LLVM_ABI void initializeInstruction()
Fills data stuctures for IRInstructionData when it is constructed from a.
SmallVector< int, 4 > RelativeBlockLocations
This structure holds the distances of how far "ahead of" or "behind" the target blocks of a branch,...
Definition IRSimilarityIdentifier.h:165
std::optional< std::string > CalleeName
This is only relevant if we are wrapping a CallInst.
Definition IRSimilarityIdentifier.h:141
LLVM_ABI IRInstructionData(Instruction &I, bool Legality, IRInstructionDataList &IDL)
Gather the information that is difficult to gather for an Instruction, or is changed.
LLVM_ABI ArrayRef< Value * > getBlockOperVals()
Get the BasicBlock based operands for PHINodes and BranchInsts.
Instruction * Inst
The source Instruction that is being wrapped.
Definition IRSimilarityIdentifier.h:119
IRInstructionDataList * IDL
Definition IRSimilarityIdentifier.h:299
static LLVM_ABI CmpInst::Predicate predicateForConsistency(CmpInst *CI)
A function that swaps the predicates to their less than form if they are in a greater than form.
LLVM_ABI void setPHIPredecessors(DenseMap< BasicBlock *, unsigned > &BasicBlockToInteger)
For an IRInstructionData containing a PHINode, finds the relative distances from the incoming basic b...
SmallVector< Value *, 4 > OperVals
The values of the operands in the Instruction.
Definition IRSimilarityIdentifier.h:121
friend hash_code hash_value(const IRInstructionData &ID)
Hashes Value based on its opcode, types, and operand types.
Definition IRSimilarityIdentifier.h:262
LLVM_ABI void setBranchSuccessors(DenseMap< BasicBlock *, unsigned > &BasicBlockToInteger)
For an IRInstructionData containing a branch, finds the relative distances from the source basic bloc...
bool Legal
The legality of the wrapped instruction.
Definition IRSimilarityIdentifier.h:126
LLVM_ABI void setCalleeName(bool MatchByName=true)
For an IRInstructionData containing a CallInst, set the function name appropriately.
LLVM_ABI CmpInst::Predicate getPredicate() const
Get the predicate that the compare instruction is using for hashing the instruction.
std::optional< CmpInst::Predicate > RevisedPredicate
This is only relevant if we are wrapping a CmpInst where we needed to change the predicate of a compa...
Definition IRSimilarityIdentifier.h:131
Custom InstVisitor to classify different instructions for whether it can be analyzed for similarity.
Definition IRSimilarityIdentifier.h:524
InstrType visitInvokeInst(InvokeInst &II)
Definition IRSimilarityIdentifier.h:582
bool EnableMustTailCalls
Definition IRSimilarityIdentifier.h:603
InstrType visitLandingPadInst(LandingPadInst &LPI)
Definition IRSimilarityIdentifier.h:545
InstrType visitFuncletPadInst(FuncletPadInst &FPI)
Definition IRSimilarityIdentifier.h:546
bool EnableIndirectCalls
Definition IRSimilarityIdentifier.h:595
InstrType visitCallInst(CallInst &CI)
Definition IRSimilarityIdentifier.h:560
InstrType visitAllocaInst(AllocaInst &AI)
Definition IRSimilarityIdentifier.h:539
InstrType visitCallBrInst(CallBrInst &CBI)
Definition IRSimilarityIdentifier.h:584
bool EnableBranches
Definition IRSimilarityIdentifier.h:591
bool EnableIntrinsics
Definition IRSimilarityIdentifier.h:599
InstructionClassification()=default
InstrType visitBranchInst(BranchInst &BI)
Definition IRSimilarityIdentifier.h:528
InstrType visitIntrinsicInst(IntrinsicInst &II)
Definition IRSimilarityIdentifier.h:547
InstrType visitInstruction(Instruction &I)
Definition IRSimilarityIdentifier.h:587
InstrType visitPHINode(PHINode &PN)
Definition IRSimilarityIdentifier.h:533
InstrType visitTerminator(Instruction &I)
Definition IRSimilarityIdentifier.h:586
InstrType visitVAArgInst(VAArgInst &VI)
Definition IRSimilarityIdentifier.h:542
Helper struct for converting the Instructions in a Module into a vector of unsigned integers.
Definition IRSimilarityIdentifier.h:380
DenseMap< IRInstructionData *, unsigned, IRInstructionDataTraits > InstructionIntegerMap
Correspondence from IRInstructionData to unsigned integers.
Definition IRSimilarityIdentifier.h:391
SpecificBumpPtrAllocator< IRInstructionDataList > * IDLAllocator
This allocator pointer is in charge of creating the IRInstructionDataList so it is not deallocated un...
Definition IRSimilarityIdentifier.h:422
SpecificBumpPtrAllocator< IRInstructionData > * InstDataAllocator
This allocator pointer is in charge of holding on to the IRInstructionData so it is not deallocated u...
Definition IRSimilarityIdentifier.h:417
bool EnableMatchCallsByName
Marks whether we should use exact function names, as well as types to find similarity between calls.
Definition IRSimilarityIdentifier.h:412
unsigned LegalInstrNumber
The next available integer to assign to a legal Instruction to.
Definition IRSimilarityIdentifier.h:387
unsigned IllegalInstrNumber
The starting illegal instruction number to map to.
Definition IRSimilarityIdentifier.h:384
InstructionClassification InstClassifier
Maps an Instruction to a member of InstrType.
Definition IRSimilarityIdentifier.h:607
void initializeForBBs(Function &F, unsigned &BBNumber)
Assigns values to all the basic blocks in function F starting from integer BBNumber.
Definition IRSimilarityIdentifier.h:457
bool HaveLegalRange
Marks whether we have found a set of instructions that is long enough to be considered for similarity...
Definition IRSimilarityIdentifier.h:408
void initializeForBBs(Module &M)
Assigns values to all the basic blocks in Module M.
Definition IRSimilarityIdentifier.h:464
LLVM_ABI IRInstructionData * allocateIRInstructionData(Instruction &I, bool Legality, IRInstructionDataList &IDL)
Get an allocated IRInstructionData struct using the InstDataAllocator.
IRInstructionMapper(SpecificBumpPtrAllocator< IRInstructionData > *IDA, SpecificBumpPtrAllocator< IRInstructionDataList > *IDLA)
Definition IRSimilarityIdentifier.h:507
bool CanCombineWithPrevInstr
Marks whether we found a illegal instruction in the previous step.
Definition IRSimilarityIdentifier.h:404
IRInstructionDataList * IDL
Definition IRSimilarityIdentifier.h:450
DenseMap< BasicBlock *, unsigned > BasicBlockToInteger
A mapping for a basic block in a module to its assigned number/location in the module.
Definition IRSimilarityIdentifier.h:395
LLVM_ABI IRInstructionDataList * allocateIRInstructionDataList()
Get an allocated IRInstructionDataList object using the IDLAllocator.
LLVM_ABI unsigned mapToLegalUnsigned(BasicBlock::iterator &It, std::vector< unsigned > &IntegerMappingForBB, std::vector< IRInstructionData * > &InstrListForBB)
Maps an Instruction to a legal integer.
LLVM_ABI void convertToUnsignedVec(BasicBlock &BB, std::vector< IRInstructionData * > &InstrList, std::vector< unsigned > &IntegerMapping)
Maps the Instructions in a BasicBlock BB to legal or illegal integers determined by InstrType.
bool AddedIllegalLastTime
Set if we added an illegal number in the previous step.
Definition IRSimilarityIdentifier.h:401
LLVM_ABI unsigned mapToIllegalUnsigned(BasicBlock::iterator &It, std::vector< unsigned > &IntegerMappingForBB, std::vector< IRInstructionData * > &InstrListForBB, bool End=false)
Maps an Instruction to an illegal integer.
DenseMap< unsigned, DenseSet< unsigned > > & ValueNumberMapping
The current mapping of global value numbers from one IRSimilarityCandidate to another IRSimilarityCan...
Definition IRSimilarityIdentifier.h:728
const IRSimilarityCandidate & IRSC
The IRSimilarityCandidate that holds the instruction the OperVals were pulled from.
Definition IRSimilarityIdentifier.h:721
ArrayRef< Value * > & OperVals
The operand values to be analyzed.
Definition IRSimilarityIdentifier.h:724
A helper struct to hold the candidate, for a branch instruction, the relative location of a label,...
Definition IRSimilarityIdentifier.h:734
const IRSimilarityCandidate & IRSC
The IRSimilarityCandidate that holds the instruction the relative location was pulled from.
Definition IRSimilarityIdentifier.h:737
int RelativeLocation
The relative location to be analyzed.
Definition IRSimilarityIdentifier.h:740
Value * OperVal
The corresponding value.
Definition IRSimilarityIdentifier.h:743
A CRTP mix-in to automatically provide informational APIs needed for passes.