-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCallFunctionGraph.h
40 lines (31 loc) · 1.05 KB
/
CallFunctionGraph.h
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
#ifndef CALL_FUNCTION_GRAPH_H
#define CALL_FUNCTION_GRAPH_H
#include "llvm/Pass.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace llvm;
class CallFunctionGraph {
public:
CallFunctionGraph(Function *EntryFunction);
void createCallGraph();
void findRecursiveCalls();
bool isRecursive(Function *F);
bool removeUnusedFunctions();
// This function is used for testing purposes only
void print();
private:
std::unordered_map<Function *, std::vector<Function *>> m_CallGraph;
Function *m_EntryFunction;
std::unordered_set<Function *> m_RecursiveFunctions;
std::unordered_set<Function *> m_UsedFunctions;
void createCallGraph(Function *F);
void findRecursiveCalls(Function *F, std::unordered_set<Function *> &Visited,
std::vector<Function *> &Path,std::unordered_set<Function *> &InPath);
};
#endif