1 Star 0 Fork 13

cf-zhao/pin-server

forked from src-openEuler/pin-server 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0006-Pin-server-Fix-bug-for-BuildCallOp.patch 4.19 KB
一键复制 编辑 原始数据 按行查看 历史
From 5be0d63fe19decadaebb012efeb03b75aa868228 Mon Sep 17 00:00:00 2001
From: Mingchuan Wu <wumingchuan1992@foxmail.com>
Date: Tue, 21 Feb 2023 16:52:39 +0800
Subject: [PATCH 06/23] [Pin-server] Fix bug for BuildCallOp. Now we can
convert the function pointer.
diff --git a/include/Dialect/PluginOps.td b/include/Dialect/PluginOps.td
index f4062ad..3a88846 100644
--- a/include/Dialect/PluginOps.td
+++ b/include/Dialect/PluginOps.td
@@ -107,11 +107,13 @@ def CallOp : Plugin_Op<"call", [
The arguments list must match the arguments expected by the callee.
}];
let arguments = (ins UI64Attr:$id,
- FlatSymbolRefAttr:$callee,
+ OptionalAttr<FlatSymbolRefAttr>:$callee,
Variadic<AnyType>:$inputs);
let builders = [
OpBuilderDAG<(ins "int64_t":$id, "StringRef":$callee,
"ArrayRef<Value>":$arguments)>,
+ OpBuilderDAG<(ins "int64_t":$id,
+ "ArrayRef<Value>":$arguments)>,
// Only for server.
OpBuilderDAG<(ins "Value":$func,
"ArrayRef<Value>":$arguments, "Block *":$block)>,
diff --git a/lib/Dialect/PluginOps.cpp b/lib/Dialect/PluginOps.cpp
index a49ce16..a30e9ed 100644
--- a/lib/Dialect/PluginOps.cpp
+++ b/lib/Dialect/PluginOps.cpp
@@ -357,6 +357,13 @@ void CallOp::build(OpBuilder &builder, OperationState &state,
state.addAttribute("callee", builder.getSymbolRefAttr(callee));
}
+void CallOp::build(OpBuilder &builder, OperationState &state,
+ int64_t id, ArrayRef<Value> arguments)
+{
+ state.addAttribute("id", builder.getI64IntegerAttr(id));
+ state.addOperands(arguments);
+}
+
/// Return the callee of the generic call operation, this is required by the
/// call interface.
CallInterfaceCallable CallOp::getCallableForCallee()
diff --git a/lib/PluginServer/PluginJson.cpp b/lib/PluginServer/PluginJson.cpp
index d89945c..7bbf681 100755
--- a/lib/PluginServer/PluginJson.cpp
+++ b/lib/PluginServer/PluginJson.cpp
@@ -467,10 +467,16 @@ mlir::Operation *PluginJson::CallOpJsonDeSerialize(const string& data)
ops.push_back(opValue);
}
int64_t id = GetID(node["id"]);
- mlir::StringRef callName(node["callee"].asString());
mlir::OpBuilder *opBuilder = PluginServer::GetInstance()->GetOpBuilder();
- CallOp op = opBuilder->create<CallOp>(opBuilder->getUnknownLoc(),
- id, callName, ops);
+ Json::Value calleeJson = node["callee"];
+ CallOp op;
+ if (calleeJson.isNull()) {
+ op = opBuilder->create<CallOp>(opBuilder->getUnknownLoc(), id, ops);
+ } else {
+ mlir::StringRef callName(calleeJson.asString());
+ op = opBuilder->create<CallOp>(opBuilder->getUnknownLoc(),
+ id, callName, ops);
+ }
return op.getOperation();
}
diff --git a/lib/PluginServer/PluginServer.cpp b/lib/PluginServer/PluginServer.cpp
index 05d0d3d..d2a1736 100644
--- a/lib/PluginServer/PluginServer.cpp
+++ b/lib/PluginServer/PluginServer.cpp
@@ -50,7 +50,7 @@ bool PluginServer::RegisterOpt(std::shared_ptr<PluginOptBase> optBase)
string name = "funcname" + std::to_string((uintptr_t)optBase.get());
userOpts[inject].push_back(RecordedOpt(name, optBase));
this->context = optBase->GetContext();
- mlir::OpBuilder opBuilder_temp = mlir::OpBuilder(context);
+ static mlir::OpBuilder opBuilder_temp = mlir::OpBuilder(context);
opBuilder = &opBuilder_temp;
return true;
}
@@ -305,7 +305,7 @@ void PluginServer::RunServer()
ServerSemPost(port);
RegisterCallbacks();
- printf("RunServer: RegisterCallbacks Done.\n");
+ log->LOGI("RunServer: RegisterCallbacks Done.\n");
pluginCom.Run();
}
} // namespace PinServer
diff --git a/lib/PluginServer/main.cpp b/lib/PluginServer/main.cpp
index fac574e..333d55e 100644
--- a/lib/PluginServer/main.cpp
+++ b/lib/PluginServer/main.cpp
@@ -29,7 +29,6 @@ int main(int argc, char** argv)
printf("param num:%d, should be:%d\n", argc, argcNum);
return -1;
}
- printf("main arg: %s, %s\n", argv[0], argv[1]);
std::string port = argv[0];
LogPriority priority = (LogPriority)atoi(argv[1]);
PluginServer server(priority, port);
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/cf-zhao/pin-server.git
git@gitee.com:cf-zhao/pin-server.git
cf-zhao
pin-server
pin-server
master

搜索帮助