[llvm-branch-commits] [llvm] [MLGO][IR2Vec] Integrating IR2Vec with MLInliner (PR #143479)
Mircea Trofin via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Jun 10 10:46:57 PDT 2025
================
@@ -186,6 +186,20 @@ MLInlineAdvisor::MLInlineAdvisor(
EdgeCount += getLocalCalls(KVP.first->getFunction());
}
NodeCount = AllNodes.size();
+
+ if (auto IR2VecVocabResult = MAM.getCachedResult<IR2VecVocabAnalysis>(M)) {
+ if (!IR2VecVocabResult->isValid()) {
+ M.getContext().emitError("IR2VecVocabAnalysis is not valid");
+ return;
+ }
+ // Add the IR2Vec features to the feature map
+ auto IR2VecDim = IR2VecVocabResult->getDimension();
+ FeatureMap.push_back(
+ TensorSpec::createSpec<float>("callee_embedding", {IR2VecDim}));
+ FeatureMap.push_back(
+ TensorSpec::createSpec<float>("caller_embedding", {IR2VecDim}));
+ UseIR2Vec = true;
----------------
mtrofin wrote:
nit: if it makes sense, you could have `const UseIR2Vec` and init it in the ctor based on `MAM.getCachedResult`. Then here, if the result isn't valid, splat the error.
main value is readability - the bool flag would say it's set once.
https://github.com/llvm/llvm-project/pull/143479
More information about the llvm-branch-commits
mailing list