|
| 1 | +// #ifndef LLVM_ANALYSIS_JUMPTABLEFINDERPASS_H |
| 2 | +// #define LLVM_ANALYSIS_JUMPTABLEFINDERPASS_H |
| 3 | + |
| 4 | +// #include "llvm/IR/PassManager.h" |
| 5 | +// #include "llvm/IR/Module.h" |
| 6 | +// #include "llvm/Support/raw_ostream.h" |
| 7 | +// #include <set> |
| 8 | + |
| 9 | +// namespace llvm { |
| 10 | + |
| 11 | +// class JumptableFinderPass : public PassInfoMixin<JumptableFinderPass> { |
| 12 | +// public: |
| 13 | +// /// Main entry point for the pass. Analyzes the module to find and analyze jump tables. |
| 14 | +// PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM); |
| 15 | +// /// Implementation of the jump table finder. |
| 16 | +// void jumptableFinderImpl(Module &M); |
| 17 | + |
| 18 | +// /// Analyze a SwitchInst for potential jump table patterns. |
| 19 | +// void findJumpTableFromSwitch(SwitchInst *SI); |
| 20 | + |
| 21 | +// /// Analyze a GetElementPtrInst for jump table patterns. |
| 22 | +// void analyzeJumpTable(GetElementPtrInst *GEP); |
| 23 | + |
| 24 | +// /// Analyze the index computation of a jump table. |
| 25 | +// void analyzeIndex(Value *Index); |
| 26 | + |
| 27 | +// /// Find all potential targets for a jump table. |
| 28 | +// void findTargets(GetElementPtrInst *GEP, std::set<BasicBlock*> &Targets); |
| 29 | + |
| 30 | +// /// Check the density of a SwitchInst's cases to determine if it forms a jump table. |
| 31 | +// bool checkDensity(SwitchInst *SI); |
| 32 | + |
| 33 | +// /// Check if a GetElementPtrInst leads to an indirect branch. |
| 34 | +// bool leadsToIndirectBranch(GetElementPtrInst *GEP); |
| 35 | +// }; |
| 36 | + |
| 37 | +// } // namespace llvm |
| 38 | + |
| 39 | +// #endif // LLVM_ANALYSIS_JUMPTABLEFINDERPASS_H |
| 40 | + |
| 41 | +#ifndef LLVM_TRANSFORMS_IPO_JUMPTABLEFINDER_H |
| 42 | +#define LLVM_TRANSFORMS_IPO_JUMPTABLEFINDER_H |
| 43 | + |
| 44 | +#include "llvm/IR/Module.h" |
| 45 | +#include "llvm/IR/PassManager.h" // For PassInfoMixin and PreservedAnalyses |
| 46 | +#include "llvm/IR/Function.h" |
| 47 | +#include "llvm/IR/Instructions.h" |
| 48 | +#include "llvm/IR/Constants.h" |
| 49 | +#include "llvm/Support/raw_ostream.h" |
| 50 | +#include <set> |
| 51 | + |
| 52 | +namespace llvm { |
| 53 | + |
| 54 | +class JumptableFinderPass : public PassInfoMixin<JumptableFinderPass> { |
| 55 | +public: |
| 56 | + // Entry point for the pass |
| 57 | + PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); |
| 58 | +}; |
| 59 | + |
| 60 | +} // namespace llvm |
| 61 | + |
| 62 | +#endif // LLVM_TRANSFORMS_IPO_JUMPTABLEFINDER_H |
0 commit comments