[llvm-branch-commits] [llvm] [MLGO][IR2Vec] Integrating IR2Vec with MLInliner (PR #143479)
S. VenkataKeerthy via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Jun 12 14:50:37 PDT 2025
================
@@ -20,33 +21,102 @@
#include "llvm/Support/Compiler.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Transforms/Utils/Cloning.h"
+#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include <cstring>
using namespace llvm;
+using namespace testing;
namespace llvm {
LLVM_ABI extern cl::opt<bool> EnableDetailedFunctionProperties;
LLVM_ABI extern cl::opt<bool> BigBasicBlockInstructionThreshold;
LLVM_ABI extern cl::opt<bool> MediumBasicBlockInstrutionThreshold;
+LLVM_ABI extern cl::opt<float> ir2vec::OpcWeight;
+LLVM_ABI extern cl::opt<float> ir2vec::TypeWeight;
+LLVM_ABI extern cl::opt<float> ir2vec::ArgWeight;
} // namespace llvm
namespace {
class FunctionPropertiesAnalysisTest : public testing::Test {
public:
FunctionPropertiesAnalysisTest() {
+ createTestVocabulary(1);
+ MAM.registerPass([&] { return IR2VecVocabAnalysis(Vocabulary); });
+ MAM.registerPass([&] { return PassInstrumentationAnalysis(); });
+ FAM.registerPass([&] { return ModuleAnalysisManagerFunctionProxy(MAM); });
FAM.registerPass([&] { return DominatorTreeAnalysis(); });
FAM.registerPass([&] { return LoopAnalysis(); });
FAM.registerPass([&] { return PassInstrumentationAnalysis(); });
+
+ ir2vec::OpcWeight = 1.0;
+ ir2vec::TypeWeight = 1.0;
+ ir2vec::ArgWeight = 1.0;
+ }
+
+private:
+ float OriginalOpcWeight = ir2vec::OpcWeight;
+ float OriginalTypeWeight = ir2vec::TypeWeight;
+ float OriginalArgWeight = ir2vec::ArgWeight;
+
+ void createTestVocabulary(unsigned Dim) {
+ Vocabulary["add"] = ir2vec::Embedding(Dim, 0.1);
----------------
svkeerthy wrote:
Simplified it using lambda. Please let me know if this is better. (Just thought this would reduce the number of lines)
https://github.com/llvm/llvm-project/pull/143479
More information about the llvm-branch-commits
mailing list