153 lines
5.6 KiB
Diff
153 lines
5.6 KiB
Diff
From 5b2e40badcd1d32180895e09edf208d052be25bf Mon Sep 17 00:00:00 2001
|
|
From: Mingchuan Wu <wumingchuan1992@foxmail.com>
|
|
Date: Mon, 27 Feb 2023 16:23:59 +0800
|
|
Subject: [PATCH 16/23] [Pin-server] Bugfix for GetFunctionById.
|
|
|
|
|
|
diff --git a/lib/PluginAPI/PluginServerAPI.cpp b/lib/PluginAPI/PluginServerAPI.cpp
|
|
index 8ef10d1..ff9c90e 100644
|
|
--- a/lib/PluginAPI/PluginServerAPI.cpp
|
|
+++ b/lib/PluginAPI/PluginServerAPI.cpp
|
|
@@ -75,6 +75,7 @@ static uint64_t GetValueId(mlir::Value v)
|
|
}
|
|
return 0;
|
|
}
|
|
+
|
|
int64_t PluginServerAPI::GetInjectDataAddress()
|
|
{
|
|
string funName = __func__;
|
|
@@ -173,24 +174,26 @@ mlir::Value PluginServerAPI::CreateSSAOp(mlir::Type t)
|
|
vector<FunctionOp> PluginServerAPI::GetAllFunc()
|
|
{
|
|
Json::Value root;
|
|
- string funName = __func__;
|
|
+ string funName = "GetFunctionIDs";
|
|
string params = root.toStyledString();
|
|
-
|
|
- return PluginServer::GetInstance()->GetFunctionOpResult(funName, params);
|
|
+ vector<FunctionOp> res;
|
|
+ vector<uint64_t> ids = PluginServer::GetInstance()->GetIdsResult(funName, params);
|
|
+ for (auto id : ids) {
|
|
+ res.push_back(GetFunctionOpById(id));
|
|
+ }
|
|
+ return res;
|
|
}
|
|
|
|
FunctionOp PluginServerAPI::GetFunctionOpById(uint64_t id)
|
|
{
|
|
- vector<FunctionOp> allFunction = GetAllFunc();
|
|
+ Json::Value root;
|
|
+ string funName = __func__;
|
|
+ root["id"] = std::to_string(id);
|
|
+ string params = root.toStyledString();
|
|
+ vector<FunctionOp> funcOps = PluginServer::GetInstance()->GetFunctionOpResult(funName, params);
|
|
FunctionOp funOp = nullptr;
|
|
-
|
|
- for (auto &funcOp : allFunction) {
|
|
- if (funcOp.id() == id) {
|
|
- funOp = funcOp;
|
|
- break;
|
|
- }
|
|
- }
|
|
- assert(funOp != nullptr);
|
|
+ if (funcOps.size())
|
|
+ funOp = funcOps[0];
|
|
return funOp;
|
|
}
|
|
|
|
diff --git a/lib/PluginServer/PluginJson.cpp b/lib/PluginServer/PluginJson.cpp
|
|
index ca75764..14a6ef4 100755
|
|
--- a/lib/PluginServer/PluginJson.cpp
|
|
+++ b/lib/PluginServer/PluginJson.cpp
|
|
@@ -587,7 +587,7 @@ void PluginJson::IdsJsonDeSerialize(
|
|
reader.parse(data, root);
|
|
Json::Value::Members operation = root.getMemberNames();
|
|
for (size_t iter = 0; iter < operation.size(); iter++) {
|
|
- string operationKey = "block" + std::to_string(iter);
|
|
+ string operationKey = "ID" + std::to_string(iter);
|
|
node = root[operationKey];
|
|
uint64_t id = GetID(node["id"]);
|
|
idsResult.push_back(id);
|
|
diff --git a/lib/PluginServer/PluginServer.cpp b/lib/PluginServer/PluginServer.cpp
|
|
index d2a1736..8778019 100644
|
|
--- a/lib/PluginServer/PluginServer.cpp
|
|
+++ b/lib/PluginServer/PluginServer.cpp
|
|
@@ -46,6 +46,10 @@ bool PluginServer::RegisterOpt(std::shared_ptr<PluginOptBase> optBase)
|
|
if ((inject >= HANDLE_MAX) || (optBase == nullptr)) {
|
|
return false;
|
|
}
|
|
+ if (inject == HANDLE_MANAGER_SETUP) {
|
|
+ log->LOGE("inject HANDLE_MANAGER_SETUP should use interface RegisterPassManagerOpt!\n");
|
|
+ return false;
|
|
+ }
|
|
|
|
string name = "funcname" + std::to_string((uintptr_t)optBase.get());
|
|
userOpts[inject].push_back(RecordedOpt(name, optBase));
|
|
diff --git a/user/ArrayWidenPass.cpp b/user/ArrayWidenPass.cpp
|
|
index 627e7f7..6fb187c 100644
|
|
--- a/user/ArrayWidenPass.cpp
|
|
+++ b/user/ArrayWidenPass.cpp
|
|
@@ -44,42 +44,6 @@ mlir::OpBuilder* opBuilder = nullptr;
|
|
std::map<Block*, Value> defs_map;
|
|
std::map<uint64_t, std::string> opNameMap;
|
|
|
|
-static void UserOptimizeFunc(void)
|
|
-{
|
|
- PluginServerAPI pluginAPI;
|
|
- vector<FunctionOp> allFunction = pluginAPI.GetAllFunc();
|
|
- int count = 0;
|
|
- for (size_t i = 0; i < allFunction.size(); i++) {
|
|
- if (allFunction[i].declaredInlineAttr().getValue())
|
|
- count++;
|
|
- }
|
|
- printf("declaredInline have %d functions were declared.\n", count);
|
|
-}
|
|
-
|
|
-static void LocalVarSummery(void)
|
|
-{
|
|
- PluginServerAPI pluginAPI;
|
|
- vector<mlir::Plugin::FunctionOp> allFunction = pluginAPI.GetAllFunc();
|
|
- map<string, string> args = PluginServer::GetInstance()->GetArgs();
|
|
- for (size_t i = 0; i < allFunction.size(); i++) {
|
|
- uint64_t funcID = allFunction[i].idAttr().getValue().getZExtValue();
|
|
- printf("In the %ldth function:\n", i);
|
|
- vector<mlir::Plugin::LocalDeclOp> decls = pluginAPI.GetDecls(funcID);
|
|
- int64_t typeFilter = -1u;
|
|
- if (args.find("type_code") != args.end()) {
|
|
- typeFilter = (int64_t)pluginAPI.GetTypeCodeFromString(args["type_code"]);
|
|
- }
|
|
- for (size_t j = 0; j < decls.size(); j++) {
|
|
- auto decl = decls[j];
|
|
- string name = decl.symNameAttr().getValue().str();
|
|
- int64_t declTypeID = decl.typeIDAttr().getValue().getZExtValue();
|
|
- if (declTypeID == typeFilter) {
|
|
- printf("\tFind %ldth target type %s\n", j, name.c_str());
|
|
- }
|
|
- }
|
|
- }
|
|
-}
|
|
-
|
|
static void PassManagerSetupFunc(void)
|
|
{
|
|
printf("PassManagerSetupFunc in\n");
|
|
@@ -1385,7 +1349,7 @@ static void create_epilogue_loop_body_bb(Block *epilogue_loop_body_bb, Block* af
|
|
|
|
Value res = g.GetLHS();
|
|
cond_stmt = opBuilder->create<CondOp>(opBuilder->getUnknownLoc(),
|
|
- llvm::dyn_cast<CondOp>(originLoop.condOp1).condCode(), res, originLoop.limit, tb, fb, (epilogue_loop_body_bb));
|
|
+ llvm::dyn_cast<CondOp>(originLoop.condOp1).condCode(), lhs2, res, tb, fb, (epilogue_loop_body_bb));
|
|
|
|
defs_map.emplace(epilogue_loop_body_bb, baseSsa.GetCurrentDef());
|
|
}
|
|
@@ -1540,6 +1504,7 @@ static void ProcessArrayWiden(uint64_t *fun)
|
|
PluginServerAPI pluginAPI;
|
|
|
|
FunctionOp funcOp = pluginAPI.GetFunctionOpById((uint64_t)fun);
|
|
+ if (funcOp == nullptr) return;
|
|
|
|
context = funcOp.getOperation()->getContext();
|
|
mlir::OpBuilder opBuilder_temp = mlir::OpBuilder(context);
|
|
--
|
|
2.33.0
|
|
|