[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
Sun Dec 7 22:06:53 PST 2025
================
@@ -249,23 +255,107 @@ class IR2VecTool {
++ArgIndex;
}
// Only update MaxRelation if there were operands
- if (ArgIndex > 0) {
+ if (ArgIndex > 0)
MaxRelation = std::max(MaxRelation, ArgRelation + ArgIndex - 1);
- }
+
PrevOpcode = Opcode;
HasPrevOpcode = true;
}
}
- return MaxRelation;
+ Result.MaxRelation = MaxRelation;
+ return Result;
}
- /// Dump entity ID to string mappings
- static void generateEntityMappings(raw_ostream &OS) {
+ TripletResult generateTriplets() const {
+ TripletResult Result;
+ Result.MaxRelation = NextRelation;
+
+ for (const Function &F : M) {
+ if (F.isDeclaration())
----------------
svkeerthy wrote:
You can consider using the newly added `getFunctionDefs` method to get the iterator range. This will automatically skip function declarations.
```
for (const Function &F : M.getFunctionDefs()) {
TripletResult FuncResult = generateTriplets(F);
...
}
```
https://github.com/llvm/llvm-project/pull/170078
More information about the llvm-commits
mailing list