================
@@ -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
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits