[llvm] [IR2Vec] Add support for flow-aware embeddings (PR #152613)

S. VenkataKeerthy via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 27 13:07:29 PDT 2025


================
@@ -196,15 +222,38 @@ void SymbolicEmbedder::computeEmbeddings(const BasicBlock &BB) const {
   BBVecMap[&BB] = BBVector;
 }
 
-void SymbolicEmbedder::computeEmbeddings() const {
-  if (F.isDeclaration())
-    return;
+void FlowAwareEmbedder::computeEmbeddings(const BasicBlock &BB) const {
+  Embedding BBVector(Dimension, 0);
 
-  // Consider only the basic blocks that are reachable from entry
-  for (const BasicBlock *BB : depth_first(&F)) {
-    computeEmbeddings(*BB);
-    FuncVector += BBVecMap[BB];
+  // We consider only the non-debug and non-pseudo instructions
+  for (const auto &I : BB.instructionsWithoutDebug()) {
+    // TODO: Handle call instructions differently.
+    // For now, we treat them like other instructions
+    Embedding ArgEmb(Dimension, 0);
----------------
svkeerthy wrote:

Makes sense. Will do it in a separate NFC.

https://github.com/llvm/llvm-project/pull/152613


More information about the llvm-commits mailing list