Repository: IITH-Compilers/IR2Vec (language: python)

Issue:
Segmentation fault when using IR2vec
I use IR2Vec to get features of some IR files (with LLVM 10.0.1), but it shows segmentation fault. Could you explain the reason about that? 
[McGill_chomp_531_32.zip](https://github.com/IITH-Compilers/IR2Vec/files/6320211/McGill_chomp_531_32.zip)




Segmentation fault when using IR2vec
I use IR2Vec to get features of some IR files (with LLVM 10.0.1), but it shows segmentation fault. Could you explain the reason about that? 
[McGill_chomp_531_32.zip](https://github.com/IITH-Compilers/IR2Vec/files/6320211/McGill_chomp_531_32.zip)






Discussion / hints:
I use the Flow-Aware representation
Hi, Thanks for bringing this up.  This seems like a bug that was introduced in some refactoring. 

I use the Flow-Aware representation
Hi, Thanks for bringing this up.  This seems like a bug that was introduced in some refactoring. 


Fix patch:
diff --git a/src/FlowAware.cpp b/src/FlowAware.cpp
index 1383ef6a..160e5cd2 100644
--- a/src/FlowAware.cpp
+++ b/src/FlowAware.cpp
@@ -36,16 +36,19 @@ void IR2Vec_FA::getTransitiveUse(
 
   for (auto U : def->users()) {
     if (auto use = dyn_cast<Instruction>(U)) {
-      IR2VEC_DEBUG(outs() << "\nDef " << /* def << */ " ";
-                   def->print(outs(), true); outs() << "\n";);
-      IR2VEC_DEBUG(outs() << "Use " << /* use << */ " ";
-                   use->print(outs(), true); outs() << "\n";);
-      if (isMemOp(use->getOpcodeName(), operandNum, memWriteOps) &&
-          use->getOperand(operandNum) == def) {
-        writeDefsMap[root].push_back(use);
-      } else if (isMemOp(use->getOpcodeName(), operandNum, memAccessOps) &&
-                 use->getOperand(operandNum) == def) {
-        getTransitiveUse(root, use, visitedList, toAppend);
+      if (std::find(visitedList.begin(), visitedList.end(), use) ==
+          visitedList.end()) {
+        IR2VEC_DEBUG(outs() << "\nDef " << /* def << */ " ";
+                     def->print(outs(), true); outs() << "\n";);
+        IR2VEC_DEBUG(outs() << "Use " << /* use << */ " ";
+                     use->print(outs(), true); outs() << "\n";);
+        if (isMemOp(use->getOpcodeName(), operandNum, memWriteOps) &&
+            use->getOperand(operandNum) == def) {
+          writeDefsMap[root].push_back(use);
+        } else if (isMemOp(use->getOpcodeName(), operandNum, memAccessOps) &&
+                   use->getOperand(operandNum) == def) {
+          getTransitiveUse(root, use, visitedList, toAppend);
+        }
       }
     }
   }


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index e1acec25..b1b5e36f 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -18,7 +18,9 @@ jobs:
 
     steps:
     - name: Install LLVM-10.0.1
-      run: wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - && sudo apt-add-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main" && sudo apt-get update && sudo apt-get install -y llvm-10 llvm-10-dev clang-10
+      run: |
+          wget https://apt.llvm.org/llvm.sh
+          sudo bash llvm.sh 10
     - uses: actions/checkout@v2
     - name: Eigen-setup
       run: |