mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
45dc6b3197
* `handleInstructionWithOSRA`: isolate usage of OSRA and increase its priority in SET. * Let SET expose, for each store to the PC (i.e. a jump), the (approximate or exact) list of destination it can have. * Extend the OperationsStack to explicitly track all the possible values that can be assumed by the instruction currently being analyzed. Note that before this patch we were only tracking possible jump targets by feeding them to JTM. The tracked values can be approximate or not, depending on the situation, and OperationsStack keeps track of this. * Clean up some leftovers from the isolation of `SET` from `SETPass`.
70 lines
1.6 KiB
C++
70 lines
1.6 KiB
C++
#ifndef _SET_H
|
|
#define _SET_H
|
|
|
|
// Standard includes
|
|
#include <set>
|
|
#include <vector>
|
|
|
|
// LLVM includes
|
|
#include "llvm/Pass.h"
|
|
|
|
// Forward declarations
|
|
namespace llvm {
|
|
class BasicBlock;
|
|
class AnalysisUsage;
|
|
class Function;
|
|
class LoadInst;
|
|
class Value;
|
|
}
|
|
|
|
class JumpTargetManager;
|
|
|
|
class SETPass : public llvm::FunctionPass {
|
|
public:
|
|
/// \brief Information about the possible destination of a jump instruction
|
|
struct JumpInfo {
|
|
JumpInfo(llvm::StoreInst *Instruction,
|
|
bool Approximate,
|
|
std::vector<uint64_t> Destinations) : Instruction(Instruction),
|
|
Approximate(Approximate),
|
|
Destinations(Destinations) { }
|
|
|
|
llvm::StoreInst *Instruction; ///< The jump instruction
|
|
bool Approximate; ///< Is the destination list approximate or exhaustive?
|
|
std::vector<uint64_t> Destinations; ///< Possible target PCs
|
|
};
|
|
|
|
|
|
public:
|
|
static char ID;
|
|
|
|
SETPass() : llvm::FunctionPass(ID),
|
|
JTM(nullptr),
|
|
Visited(nullptr),
|
|
UseOSRA(false) { }
|
|
|
|
SETPass(JumpTargetManager *JTM,
|
|
bool UseOSRA,
|
|
std::set<llvm::BasicBlock *> *Visited) :
|
|
llvm::FunctionPass(ID),
|
|
JTM(JTM),
|
|
Visited(Visited),
|
|
UseOSRA(UseOSRA) { }
|
|
|
|
bool runOnFunction(llvm::Function &F) override;
|
|
|
|
void getAnalysisUsage(llvm::AnalysisUsage &AU) const override;
|
|
|
|
const std::vector<JumpInfo> &jumps() const {
|
|
return Jumps;
|
|
}
|
|
|
|
private:
|
|
JumpTargetManager *JTM;
|
|
std::set<llvm::BasicBlock *> *Visited;
|
|
bool UseOSRA;
|
|
std::vector<JumpInfo> Jumps;
|
|
};
|
|
|
|
#endif // _SET_H
|