[llvm] e29bb9a - [IR2Vec] Consider only reachable BBs and non-debug instructions (#143476)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 17 10:57:56 PDT 2025
Author: S. VenkataKeerthy
Date: 2025-06-17T10:57:52-07:00
New Revision: e29bb9a038245320164c5890d1a75843e4a664ef
URL: https://github.com/llvm/llvm-project/commit/e29bb9a038245320164c5890d1a75843e4a664ef
DIFF: https://github.com/llvm/llvm-project/commit/e29bb9a038245320164c5890d1a75843e4a664ef.diff
LOG: [IR2Vec] Consider only reachable BBs and non-debug instructions (#143476)
Changes to consider BBs that are reachable from the entry block. Similarly we skip debug instruction while computing the embeddings.
(Tracking issue - #141817)
Added:
Modified:
llvm/lib/Analysis/IR2Vec.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/IR2Vec.cpp b/llvm/lib/Analysis/IR2Vec.cpp
index 0f7303c1b0917..fa38c35796a0e 100644
--- a/llvm/lib/Analysis/IR2Vec.cpp
+++ b/llvm/lib/Analysis/IR2Vec.cpp
@@ -13,7 +13,9 @@
#include "llvm/Analysis/IR2Vec.h"
+#include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/ADT/Statistic.h"
+#include "llvm/IR/CFG.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PassManager.h"
#include "llvm/Support/Debug.h"
@@ -190,7 +192,8 @@ Embedding SymbolicEmbedder::getOperandEmbedding(const Value *Op) const {
void SymbolicEmbedder::computeEmbeddings(const BasicBlock &BB) const {
Embedding BBVector(Dimension, 0);
- for (const auto &I : BB) {
+ // We consider only the non-debug and non-pseudo instructions
+ for (const auto &I : BB.instructionsWithoutDebug()) {
Embedding InstVector(Dimension, 0);
const auto OpcVec = lookupVocab(I.getOpcodeName());
@@ -215,9 +218,11 @@ void SymbolicEmbedder::computeEmbeddings(const BasicBlock &BB) const {
void SymbolicEmbedder::computeEmbeddings() const {
if (F.isDeclaration())
return;
- for (const auto &BB : F) {
- computeEmbeddings(BB);
- FuncVector += BBVecMap[&BB];
+
+ // Consider only the basic blocks that are reachable from entry
+ for (const BasicBlock *BB : depth_first(&F)) {
+ computeEmbeddings(*BB);
+ FuncVector += BBVecMap[BB];
}
}
More information about the llvm-commits
mailing list