Skip to content

Commit ed6b42b

Browse files
committed
pre-commit changes
1 parent 873ec79 commit ed6b42b

6 files changed

Lines changed: 36 additions & 29 deletions

File tree

src/FlowAware.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,14 +216,15 @@ void IR2Vec_FA::updateFuncVecMap(
216216
}
217217

218218
void IR2Vec_FA::generateFlowAwareEncodingsForFunction(
219-
std::ostream *o, llvm::Function *FuncPtr, std::string funcName, std::ostream *missCount,
220-
std::ostream *cyclicCount) {
219+
std::ostream *o, llvm::Function *FuncPtr, std::string funcName,
220+
std::ostream *missCount, std::ostream *cyclicCount) {
221221

222222
int noOfFunc = 0;
223223
for (auto &f : M) {
224224

225225
auto Result = getActualName(&f);
226-
if (!f.isDeclaration() && ((FuncPtr && &f == FuncPtr) || (!funcName.empty() && Result == funcName))) {
226+
if (!f.isDeclaration() && ((FuncPtr && &f == FuncPtr) ||
227+
(!funcName.empty() && Result == funcName))) {
227228
// If funcName is matched with one of the functions in module, we
228229
// will update funcVecMap of it and it's child functions recursively
229230
llvm::SmallSet<const Function *, 16> visitedFunctions;
@@ -241,7 +242,8 @@ void IR2Vec_FA::generateFlowAwareEncodingsForFunction(
241242

242243
for (auto &f : M) {
243244
auto Result = getActualName(&f);
244-
if (!f.isDeclaration() && ((FuncPtr && &f == FuncPtr) || (!funcName.empty() && Result == funcName))) {
245+
if (!f.isDeclaration() && ((FuncPtr && &f == FuncPtr) ||
246+
(!funcName.empty() && Result == funcName))) {
245247
Vector tmp;
246248
SmallVector<Function *, 15> funcStack;
247249
tmp = funcVecMap[&f];

src/Symbolic.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,16 @@ void IR2Vec_Symbolic::generateSymbolicEncodings(std::ostream *o) {
8080
}
8181

8282
// for generating symbolic encodings for specific function
83-
void IR2Vec_Symbolic::generateSymbolicEncodingsForFunction(std::ostream *o,
84-
llvm::Function *FuncPtr, std::string funcName) {
83+
void IR2Vec_Symbolic::generateSymbolicEncodingsForFunction(
84+
std::ostream *o, llvm::Function *FuncPtr, std::string funcName) {
8585
int noOfFunc = 0;
8686
llvm::errs() << "inside the correct generateSymbolicEncodingsForFunction\n";
8787
for (auto &f : M) {
8888
auto Result = getActualName(&f);
89-
if (!f.isDeclaration() && ((FuncPtr && &f == FuncPtr) || (!funcName.empty() && Result == funcName))) {
90-
llvm::errs () << "is not match happening in the if condition?"<< "\n";
89+
if (!f.isDeclaration() && ((FuncPtr && &f == FuncPtr) ||
90+
(!funcName.empty() && Result == funcName))) {
91+
llvm::errs() << "is not match happening in the if condition?"
92+
<< "\n";
9193
Vector tmp;
9294
SmallVector<Function *, 15> funcStack;
9395
tmp = func2Vec(f, funcStack);
@@ -107,7 +109,7 @@ void IR2Vec_Symbolic::generateSymbolicEncodingsForFunction(std::ostream *o,
107109
Vector IR2Vec_Symbolic::func2Vec(Function &F,
108110
SmallVector<Function *, 15> &funcStack) {
109111

110-
llvm::errs () << "is it entering func2Vec?\n";
112+
llvm::errs() << "is it entering func2Vec?\n";
111113
auto It = funcVecMap.find(&F);
112114
if (It != funcVecMap.end()) {
113115
return It->second;
@@ -136,7 +138,7 @@ Vector IR2Vec_Symbolic::func2Vec(Function &F,
136138
Vector IR2Vec_Symbolic::bb2Vec(BasicBlock &B,
137139
SmallVector<Function *, 15> &funcStack) {
138140

139-
llvm::errs () << "is it entering bb2Vec?\n";
141+
llvm::errs() << "is it entering bb2Vec?\n";
140142
auto It = bbVecMap.find(&B);
141143
if (It != bbVecMap.end()) {
142144
return It->second;

src/include/FlowAware.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,9 @@ class IR2Vec_FA {
176176
// newly added
177177

178178
void generateFlowAwareEncodingsForFunction(
179-
std::ostream *o = nullptr, llvm::Function *FuncPtr = nullptr, std::string funcName="",
180-
std::ostream *missCount = nullptr, std::ostream *cyclicCount = nullptr);
179+
std::ostream *o = nullptr, llvm::Function *FuncPtr = nullptr,
180+
std::string funcName = "", std::ostream *missCount = nullptr,
181+
std::ostream *cyclicCount = nullptr);
181182

182183
llvm::SmallMapVector<const llvm::Instruction *, IR2Vec::Vector, 128>
183184
getInstVecMap() {

src/include/IR2Vec.h

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ enum IR2VecMode { FlowAware, Symbolic };
2020

2121
class Embeddings {
2222
int generateEncodings(llvm::Module &M, IR2VecMode mode, char level = '\0',
23-
std::string funcName = "", llvm::Function* FuncPtr = nullptr, unsigned dim = 300,
23+
std::string funcName = "",
24+
llvm::Function *FuncPtr = nullptr, unsigned dim = 300,
2425
std::ostream *o = nullptr, int cls = -1, float WO = 1,
2526
float WA = 0.2, float WT = 0.5);
2627

@@ -33,32 +34,30 @@ class Embeddings {
3334
public:
3435
Embeddings() = default;
3536

36-
// Constructor with function pointer
37-
Embeddings(llvm::Module &M, IR2VecMode mode, llvm::Function *FuncPtr=nullptr, unsigned dim = 300,
38-
float WO = 1, float WA = 0.2,
39-
float WT = 0.5) {
37+
// Constructor with function pointer
38+
Embeddings(llvm::Module &M, IR2VecMode mode,
39+
llvm::Function *FuncPtr = nullptr, unsigned dim = 300,
40+
float WO = 1, float WA = 0.2, float WT = 0.5) {
4041
vocabulary = VocabularyFactory::createVocabulary(dim)->getVocabulary();
4142
generateEncodings(M, mode, '\0', "", FuncPtr, dim, nullptr, -1, WO, WA, WT);
4243
}
4344

44-
45-
Embeddings(llvm::Module &M, IR2VecMode mode, std::string funcName="", unsigned dim = 300,
46-
float WO = 1, float WA = 0.2,
47-
float WT = 0.5) {
45+
Embeddings(llvm::Module &M, IR2VecMode mode, std::string funcName = "",
46+
unsigned dim = 300, float WO = 1, float WA = 0.2, float WT = 0.5) {
4847
vocabulary = VocabularyFactory::createVocabulary(dim)->getVocabulary();
49-
generateEncodings(M, mode, '\0', funcName, nullptr, dim, nullptr, -1, WO, WA, WT);
48+
generateEncodings(M, mode, '\0', funcName, nullptr, dim, nullptr, -1, WO,
49+
WA, WT);
5050
}
5151

52-
53-
5452
// Use this constructor if the representations ought to be written to a
5553
// file. Analogous to the command line options that are being used in IR2Vec
5654
// binary.
5755
Embeddings(llvm::Module &M, IR2VecMode mode, char level, std::ostream *o,
58-
std::string funcName="", unsigned dim = 300, float WO = 1,
56+
std::string funcName = "", unsigned dim = 300, float WO = 1,
5957
float WA = 0.2, float WT = 0.5) {
6058
vocabulary = VocabularyFactory::createVocabulary(dim)->getVocabulary();
61-
generateEncodings(M, mode, level, funcName, nullptr, dim, o, -1, WO, WA, WT);
59+
generateEncodings(M, mode, level, funcName, nullptr, dim, o, -1, WO, WA,
60+
WT);
6261
}
6362

6463
// Returns a map containing instructions and the corresponding vector

src/include/Symbolic.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ class IR2Vec_Symbolic {
4747

4848
void generateSymbolicEncodings(std::ostream *o = nullptr);
4949
void generateSymbolicEncodingsForFunction(std::ostream *o = nullptr,
50-
llvm::Function *FuncPtr = nullptr, std::string funcName = "");
50+
llvm::Function *FuncPtr = nullptr,
51+
std::string funcName = "");
5152
llvm::SmallMapVector<const llvm::Instruction *, IR2Vec::Vector, 128>
5253
getInstVecMap() {
5354
return instVecMap;

src/libIR2Vec.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717

1818
int IR2Vec::Embeddings::generateEncodings(llvm::Module &M,
1919
IR2Vec::IR2VecMode mode, char level,
20-
std::string funcName, llvm::Function* FuncPtr, unsigned dim,
20+
std::string funcName,
21+
llvm::Function *FuncPtr, unsigned dim,
2122
std::ostream *o, int cls, float WO,
2223
float WA, float WT) {
2324

@@ -50,7 +51,8 @@ int IR2Vec::Embeddings::generateEncodings(llvm::Module &M,
5051
pgmVector = FA.getProgramVector();
5152
}
5253
} else if (mode == IR2Vec::IR2VecMode::Symbolic) {
53-
llvm::errs () << "is it correctly entering here?" << "\n";
54+
llvm::errs() << "is it correctly entering here?"
55+
<< "\n";
5456
IR2Vec_Symbolic SYM(M, vocabulary);
5557

5658
if (FuncPtr || !funcName.empty()) {

0 commit comments

Comments
 (0)