[llvm] Refactoring llvm-ir2vec.cpp for better separation of concerns in the Tooling classes (PR #170078)
Nishant Sachdeva via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 10 01:00:53 PST 2025
================
@@ -182,32 +200,16 @@ class IR2VecTool {
return Vocab->isValid();
}
- /// Generate triplets for the module
- /// Output format: MAX_RELATION=N header followed by relationships
- void generateTriplets(raw_ostream &OS) const {
- unsigned MaxRelation = NextRelation; // Track maximum relation ID
- std::string Relationships;
- raw_string_ostream RelOS(Relationships);
-
- for (const Function &F : M) {
- unsigned FuncMaxRelation = generateTriplets(F, RelOS);
- MaxRelation = std::max(MaxRelation, FuncMaxRelation);
- }
-
- RelOS.flush();
-
- // Write metadata header followed by relationships
- OS << "MAX_RELATION=" << MaxRelation << '\n';
- OS << Relationships;
- }
-
/// Generate triplets for a single function
/// Returns the maximum relation ID used in this function
----------------
nishant-sachdeva wrote:
Correctly spotted. The comment misses the default case. I'll change this comment to
```
/// Generate triplets for a single function
/// Returns the maximum relation ID used in this function,
/// or NextRelation if no Arg relations were created
```
https://github.com/llvm/llvm-project/pull/170078
More information about the llvm-commits
mailing list