13
13
14
14
#include " llvm/Analysis/IR2Vec.h"
15
15
16
+ #include " llvm/ADT/DepthFirstIterator.h"
16
17
#include " llvm/ADT/Statistic.h"
18
+ #include " llvm/IR/CFG.h"
17
19
#include " llvm/IR/Module.h"
18
20
#include " llvm/IR/PassManager.h"
19
21
#include " llvm/Support/Debug.h"
@@ -190,7 +192,8 @@ Embedding SymbolicEmbedder::getOperandEmbedding(const Value *Op) const {
190
192
void SymbolicEmbedder::computeEmbeddings (const BasicBlock &BB) const {
191
193
Embedding BBVector (Dimension, 0 );
192
194
193
- for (const auto &I : BB) {
195
+ // We consider only the non-debug and non-pseudo instructions
196
+ for (const auto &I : BB.instructionsWithoutDebug ()) {
194
197
Embedding InstVector (Dimension, 0 );
195
198
196
199
const auto OpcVec = lookupVocab (I.getOpcodeName ());
@@ -215,9 +218,11 @@ void SymbolicEmbedder::computeEmbeddings(const BasicBlock &BB) const {
215
218
void SymbolicEmbedder::computeEmbeddings () const {
216
219
if (F.isDeclaration ())
217
220
return ;
218
- for (const auto &BB : F) {
219
- computeEmbeddings (BB);
220
- FuncVector += BBVecMap[&BB];
221
+
222
+ // Consider only the basic blocks that are reachable from entry
223
+ for (const BasicBlock *BB : depth_first (&F)) {
224
+ computeEmbeddings (*BB);
225
+ FuncVector += BBVecMap[BB];
221
226
}
222
227
}
223
228
0 commit comments