forked from soumitrachatterjee/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode22.cpp
35 lines (28 loc) · 1011 Bytes
/
code22.cpp
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
#include "llvm/Pass.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/InstVisitor.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
namespace {
class MemoryAccessAnalysis : public FunctionPass, public InstVisitor<MemoryAccessAnalysis> {
public:
static char ID;
MemoryAccessAnalysis() : FunctionPass(ID) {}
bool runOnFunction(Function &F) override {
errs() << "Analyzing memory accesses in function: " << F.getName() << "\n";
visit(F);
return false;
}
// Visit LoadInst and StoreInst to analyze memory accesses
void visitLoadInst(LoadInst &I) {
errs() << "Load instruction: " << I << "\n";
// Add your analysis code here for load instructions
}
void visitStoreInst(StoreInst &I) {
errs() << "Store instruction: " << I << "\n";
// Add your analysis code here for store instructions
}
};
} // namespace
char MemoryAccessAnalysis::ID = 0;
static RegisterPass<MemoryAccessAnalysis> X("memory-access-details", "Memory Access Details", false, false);