forked from revng/revng
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcollectcfg.h
50 lines (38 loc) · 1.02 KB
/
collectcfg.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
41
42
43
44
45
46
47
48
49
50
#ifndef _COLLECTCFG_H
#define _COLLECTCFG_H
//
// This file is distributed under the MIT License. See LICENSE.md for details.
//
// Standard includes
#include <fstream>
#include <map>
#include <set>
// LLVM includes
#include "llvm/Pass.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
template<typename T>
struct CompareByName {
bool operator()(const T *LHS, const T *RHS) const {
return LHS->getName() < RHS->getName();
}
};
class CollectCFG : public llvm::FunctionPass {
public:
static char ID;
public:
CollectCFG() : llvm::FunctionPass(ID) { }
bool runOnFunction(llvm::Function &F) override;
void getAnalysisUsage(llvm::AnalysisUsage &AU) const override {
AU.setPreservesAll();
}
void serialize(std::ostream &Output);
private:
bool isNewInstruction(llvm::BasicBlock *BB);
private:
std::map<llvm::BasicBlock *,
llvm::SmallVector<llvm::BasicBlock *, 2>,
CompareByName<llvm::BasicBlock>> Result;
std::set<llvm::BasicBlock *> BlackList;
};
#endif // _COLLECTCFG_H