[llvm] Refactoring llvm-ir2vec.cpp for better separation of concerns in the Tooling classes (PR #170078)

S. VenkataKeerthy via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 1 23:14:10 PST 2025


================
@@ -547,48 +649,93 @@ class MIR2VecTool {
     }
   }
 
-  /// Generate embeddings for a specific machine function
-  void generateEmbeddings(MachineFunction &MF, raw_ostream &OS) const {
+  /// Get machine function embedding
+  /// Returns Embedding for the entire machine function
+  ir2vec::Embedding getMFunctionEmbedding(MachineFunction &MF) const {
     if (!Vocab) {
       WithColor::error(errs(), ToolName) << "Vocabulary not initialized.\n";
-      return;
+      return {};
     }
 
     auto Emb = MIREmbedder::create(MIR2VecKind::Symbolic, MF, *Vocab);
-    if (!Emb) {
-      WithColor::error(errs(), ToolName)
-          << "Failed to create embedder for " << MF.getName() << "\n";
+    return Emb ? Emb->getMFunctionVector() : ir2vec::Embedding{};
----------------
svkeerthy wrote:

Here and other places..

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


More information about the llvm-commits mailing list