class IRSimilarityIdentifier
Declaration
class IRSimilarityIdentifier { /* full declaration omitted */ };
Description
This class puts all the pieces of the IRInstructionData, IRInstructionMapper, IRSimilarityCandidate together. It first feeds the Module or vector of Modules into the IRInstructionMapper, and puts all the mapped instructions into a single long list of IRInstructionData. The list of unsigned integers is given to the Suffix Tree or similar data structure to find repeated subsequences. We construct an IRSimilarityCandidate for each instance of the subsequence. We compare them against one another since These repeated subsequences can have different structure. For each different kind of structure found, we create a similarity group. If we had four IRSimilarityCandidates A, B, C, and D where A, B and D are structurally similar to one another, while C is different we would have two SimilarityGroups: SimilarityGroup 1: SimilarityGroup 2 A, B, D C A list of the different similarity groups is then returned after analyzing the module.
Declared at: llvm/include/llvm/Analysis/IRSimilarityIdentifier.h:978
Member Variables
- private SpecificBumpPtrAllocator< llvm::IRSimilarity::IRInstructionData> InstDataAllocator
- The allocator for IRInstructionData.
- private SpecificBumpPtrAllocator< llvm::IRSimilarity::IRInstructionDataList> InstDataListAllocator
- The allocator for IRInstructionDataLists.
- private llvm::IRSimilarity::IRInstructionMapper Mapper
- Map Instructions to unsigned integers and wraps the Instruction in an instance of IRInstructionData.
- private bool EnableBranches = true
- The flag variable that marks whether we should check branches for similarity, or only look within basic blocks.
- private bool EnableIndirectCalls = true
- The flag variable that marks whether we allow indirect calls to be checked for similarity, or exclude them as a legal instruction.
- private bool EnableMatchingCallsByName = true
- The flag variable that marks whether we allow calls to be marked as similar if they do not have the same name, only the same calling convention, attributes and type signature.
- private bool EnableIntrinsics = true
- The flag variable that marks whether we should check intrinsics for similarity.
- private bool EnableMustTailCalls = false
- private Optional<llvm::IRSimilarity::SimilarityGroupList> SimilarityCandidates
- The SimilarityGroups found with the most recent run of \ref findSimilarity. None if there is no recent run.
Method Overview
- public IRSimilarityIdentifier(bool MatchBranches = true, bool MatchIndirectCalls = true, bool MatchCallsWithName = false, bool MatchIntrinsics = true, bool MatchMustTailCalls = true)
- private void findCandidates(std::vector<IRInstructionData *> & InstrList, std::vector<unsigned int> & IntegerMapping)
- public llvm::IRSimilarity::SimilarityGroupList & findSimilarity(ArrayRef<std::unique_ptr<Module>> Modules)
- public llvm::IRSimilarity::SimilarityGroupList & findSimilarity(llvm::Module & M)
- public Optional<llvm::IRSimilarity::SimilarityGroupList> & getSimilarity()
- private void populateMapper(llvm::Module & M, std::vector<IRInstructionData *> & InstrList, std::vector<unsigned int> & IntegerMapping)
- private void populateMapper(ArrayRef<std::unique_ptr<Module>> & Modules, std::vector<IRInstructionData *> & InstrList, std::vector<unsigned int> & IntegerMapping)
- public void resetSimilarityCandidates()
Methods
¶IRSimilarityIdentifier(
bool MatchBranches = true,
bool MatchIndirectCalls = true,
bool MatchCallsWithName = false,
bool MatchIntrinsics = true,
bool MatchMustTailCalls = true)
IRSimilarityIdentifier(
bool MatchBranches = true,
bool MatchIndirectCalls = true,
bool MatchCallsWithName = false,
bool MatchIntrinsics = true,
bool MatchMustTailCalls = true)
Declared at: llvm/include/llvm/Analysis/IRSimilarityIdentifier.h:980
Parameters
- bool MatchBranches = true
- bool MatchIndirectCalls = true
- bool MatchCallsWithName = false
- bool MatchIntrinsics = true
- bool MatchMustTailCalls = true
¶void findCandidates(
std::vector<IRInstructionData*>& InstrList,
std::vector<unsigned int>& IntegerMapping)
void findCandidates(
std::vector<IRInstructionData*>& InstrList,
std::vector<unsigned int>& IntegerMapping)
Description
Find the similarity candidates in \p InstrList and corresponding\p UnsignedVec
Declared at: llvm/include/llvm/Analysis/IRSimilarityIdentifier.h:1017
Parameters
- std::vector<IRInstructionData*>& InstrList
- - The vector to append IRInstructionData to.
- std::vector<unsigned int>& IntegerMapping
- - The vector to append integers to. candidates found in the program.
¶llvm::IRSimilarity::SimilarityGroupList&
findSimilarity(
ArrayRef<std::unique_ptr<Module>> Modules)
llvm::IRSimilarity::SimilarityGroupList&
findSimilarity(
ArrayRef<std::unique_ptr<Module>> Modules)
Declared at: llvm/include/llvm/Analysis/IRSimilarityIdentifier.h:1028
Parameters
- ArrayRef<std::unique_ptr<Module>> Modules
¶llvm::IRSimilarity::SimilarityGroupList&
findSimilarity(llvm::Module& M)
llvm::IRSimilarity::SimilarityGroupList&
findSimilarity(llvm::Module& M)
Declared at: llvm/include/llvm/Analysis/IRSimilarityIdentifier.h:1035
Parameters
- llvm::Module& M
¶Optional<llvm::IRSimilarity::SimilarityGroupList>&
getSimilarity()
Optional<llvm::IRSimilarity::SimilarityGroupList>&
getSimilarity()
Declared at: llvm/include/llvm/Analysis/IRSimilarityIdentifier.h:1050
¶void populateMapper(
llvm::Module& M,
std::vector<IRInstructionData*>& InstrList,
std::vector<unsigned int>& IntegerMapping)
void populateMapper(
llvm::Module& M,
std::vector<IRInstructionData*>& InstrList,
std::vector<unsigned int>& IntegerMapping)
Description
Map the instructions in the module to unsigned integers, using mapping already present in the Mapper if possible.
Declared at: llvm/include/llvm/Analysis/IRSimilarityIdentifier.h:998
Parameters
- llvm::Module& M
- Module - To map to integers.
- std::vector<IRInstructionData*>& InstrList
- - The vector to append IRInstructionData to.
- std::vector<unsigned int>& IntegerMapping
- - The vector to append integers to.
¶void populateMapper(
ArrayRef<std::unique_ptr<Module>>& Modules,
std::vector<IRInstructionData*>& InstrList,
std::vector<unsigned int>& IntegerMapping)
void populateMapper(
ArrayRef<std::unique_ptr<Module>>& Modules,
std::vector<IRInstructionData*>& InstrList,
std::vector<unsigned int>& IntegerMapping)
Description
Map the instructions in the modules vector to unsigned integers, using mapping already present in the mapper if possible.
Declared at: llvm/include/llvm/Analysis/IRSimilarityIdentifier.h:1007
Parameters
- ArrayRef<std::unique_ptr<Module>>& Modules
- - The list of modules to use to populate the mapper
- std::vector<IRInstructionData*>& InstrList
- - The vector to append IRInstructionData to.
- std::vector<unsigned int>& IntegerMapping
- - The vector to append integers to.
¶void resetSimilarityCandidates()
void resetSimilarityCandidates()
Declared at: llvm/include/llvm/Analysis/IRSimilarityIdentifier.h:1038