Skip to content

Commit 40402d2

Browse files
committed
reachable BB
1 parent 09c54c2 commit 40402d2

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

llvm/lib/Analysis/IR2Vec.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313

1414
#include "llvm/Analysis/IR2Vec.h"
1515

16+
#include "llvm/ADT/DepthFirstIterator.h"
1617
#include "llvm/ADT/Statistic.h"
18+
#include "llvm/IR/CFG.h"
1719
#include "llvm/IR/Module.h"
1820
#include "llvm/IR/PassManager.h"
1921
#include "llvm/Support/Debug.h"
@@ -190,7 +192,8 @@ Embedding SymbolicEmbedder::getOperandEmbedding(const Value *Op) const {
190192
void SymbolicEmbedder::computeEmbeddings(const BasicBlock &BB) const {
191193
Embedding BBVector(Dimension, 0);
192194

193-
for (const auto &I : BB) {
195+
// We consider only the non-debug and non-pseudo instructions
196+
for (const auto &I : BB.instructionsWithoutDebug()) {
194197
Embedding InstVector(Dimension, 0);
195198

196199
const auto OpcVec = lookupVocab(I.getOpcodeName());
@@ -215,9 +218,11 @@ void SymbolicEmbedder::computeEmbeddings(const BasicBlock &BB) const {
215218
void SymbolicEmbedder::computeEmbeddings() const {
216219
if (F.isDeclaration())
217220
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];
221226
}
222227
}
223228

0 commit comments

Comments
 (0)