@@ -196,41 +196,77 @@ void IR2Vec_FA::generateFlowAwareEncodings(std::ostream *o,
196196void IR2Vec_FA::updateFuncVecMap (
197197 llvm::Function *function,
198198 llvm::SmallSet<const llvm::Function *, 16 > &visitedFunctions) {
199+
200+ if (!function) {
201+ llvm::errs () << " Received a nullptr function, skipping updateFuncVecMap.\n " ;
202+ return ;
203+ }
204+
205+ llvm::errs () << " Processing function: " << function->getName () << " \n " ;
206+
199207 visitedFunctions.insert (function);
200208 SmallVector<Function *, 15 > funcStack;
201209 funcStack.clear ();
210+ llvm::errs () << " reaching updateFuncVecMap?" << " \n " ;
211+
202212 auto tmpParent = func2Vec (*function, funcStack);
213+
214+ llvm::errs () << " is there any issue in creating the func2Vec embeddings?" << " \n " ;
203215 // funcVecMap is updated with vectors returned by func2Vec
216+
217+ llvm::errs () << " what is tmpParent here?" << " \n " ;
218+ for (auto v:tmpParent){
219+ llvm::errs () << v<< " ," ;
220+ }
221+ llvm::errs () << " \n " ;
204222 funcVecMap[function] = tmpParent;
205223 auto calledFunctions = funcCallMap[function];
224+
225+ llvm::errs () << " vector of calledFunctions: " << " \n " ;
226+ for (auto x:calledFunctions){
227+ llvm::errs () << x<< " ," ;
228+ }
229+ llvm::errs () << " \n " ;
230+
231+ if (calledFunctions.empty ()) return ;
232+
206233 for (auto &calledFunction : calledFunctions) {
207234 if (calledFunction && !calledFunction->isDeclaration () &&
208235 visitedFunctions.count (calledFunction) == 0 ) {
209236 // doing casting since calledFunctions is of type of const
210237 // llvm::Function* and we need llvm::Function* as argument
211238 auto *callee = const_cast <Function *>(calledFunction);
212239 // This function is called recursively to update funcVecMap
240+ llvm::errs () << " Calling updateFuncVecMap for function: " << callee->getName () << " \n " ;
213241 updateFuncVecMap (callee, visitedFunctions);
214242 }
215243 }
244+ llvm::errs () << " is it coming out of this loop in updateFVM?" << " \n " ;
216245}
217246
218247void IR2Vec_FA::generateFlowAwareEncodingsForFunction (
219248 std::ostream *o, llvm::Function *FuncPtr, std::string funcName,
220249 std::ostream *missCount, std::ostream *cyclicCount) {
221-
250+ llvm::errs () << " able to enter genFAforFunc " << " \n " ;
222251 int noOfFunc = 0 ;
223252 for (auto &f : M) {
224-
253+ llvm::errs () << " before getActualName " << " \n " ;
225254 auto Result = getActualName (&f);
226- if (!f.isDeclaration () && ((FuncPtr && &f == FuncPtr) ||
227- (!funcName.empty () && Result == funcName))) {
255+ llvm::errs () << " what is Result here? " << " \n " ;
256+
257+ // if (!f.isDeclaration() && ((FuncPtr && &f == FuncPtr) ||
258+ // (!funcName.empty() && Result == funcName))) {
259+ if (!f.isDeclaration () && ((FuncPtr && &f == FuncPtr))){
228260 // If funcName is matched with one of the functions in module, we
229261 // will update funcVecMap of it and it's child functions recursively
262+ llvm::errs () << " able to get a match for the fucn name and ptr" << " \n " ;
230263 llvm::SmallSet<const Function *, 16 > visitedFunctions;
231264 updateFuncVecMap (&f, visitedFunctions);
265+ llvm:errs () << " just after updateFuncVecMap" << " \n " ;
232266 }
233267 }
268+
269+ llvm::errs () << " is it going out of the loop1?" << " \n " ;
234270 // iterating over all functions in module instead of funcVecMap to preserve
235271 // order
236272 for (auto &f : M) {
@@ -240,10 +276,15 @@ void IR2Vec_FA::generateFlowAwareEncodingsForFunction(
240276 }
241277 }
242278
279+ llvm::errs () << " is it coming out of loop2?" << " \n " ;
280+
243281 for (auto &f : M) {
244282 auto Result = getActualName (&f);
245- if (!f.isDeclaration () && ((FuncPtr && &f == FuncPtr) ||
246- (!funcName.empty () && Result == funcName))) {
283+ // if (!f.isDeclaration() && ((FuncPtr && &f == FuncPtr) ||
284+ // (!funcName.empty() && Result == funcName))) {
285+
286+ if (!f.isDeclaration () && ((FuncPtr && &f == FuncPtr))){
287+ llvm::errs () << " able to get a match for the fucn name and ptr part2" << " \n " ;
247288 Vector tmp;
248289 SmallVector<Function *, 15 > funcStack;
249290 tmp = funcVecMap[&f];
0 commit comments