diff --git a/0026-Pin-server-Fix-log-output-form.patch b/0026-Pin-server-Fix-log-output-form.patch new file mode 100644 index 0000000000000000000000000000000000000000..343ea4fa1c5dd8a5ca850da506762228c2f9e7bc --- /dev/null +++ b/0026-Pin-server-Fix-log-output-form.patch @@ -0,0 +1,254 @@ +From 61f8e5ee493220d7571ac7d3bf730d6856660753 Mon Sep 17 00:00:00 2001 +From: d00573793 +Date: Mon, 20 Mar 2023 21:45:03 +0800 +Subject: [PATCH] [Pin-server] Fix log output form + + +diff --git a/lib/PluginAPI/PluginServerAPI.cpp b/lib/PluginAPI/PluginServerAPI.cpp +index 273aafe..09bd358 100644 +--- a/lib/PluginAPI/PluginServerAPI.cpp ++++ b/lib/PluginAPI/PluginServerAPI.cpp +@@ -27,7 +27,7 @@ using namespace mlir::Plugin; + static bool CheckAttribute(string &attribute) + { + if (attribute == "NULL") { +- printf("param attribute is NULL,check fail!\n"); ++ fprintf(stderr, "param attribute is NULL,check fail!\n"); + return false; + } + return true; +diff --git a/lib/PluginServer/PluginLog.cpp b/lib/PluginServer/PluginLog.cpp +index 9c0a08f..10b8bc8 100644 +--- a/lib/PluginServer/PluginLog.cpp ++++ b/lib/PluginServer/PluginLog.cpp +@@ -47,14 +47,14 @@ void PluginLog::GetLogFileName(string& fileName) + { + time_t nowTime = time(nullptr); + if (nowTime == -1) { +- printf("%s fail\n", __func__); ++ fprintf(stderr, "%s fail\n", __func__); + } + struct tm *t = localtime(&nowTime); + char buf[100]; + int ret = sprintf(buf, "/tmp/pin_server%d_%4d%02d%02d_%02d_%02d_%02d.log", getppid(), + t->tm_year + BASE_DATE, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec); + if (ret < 0) { +- printf("%s sprintf fail\n", __func__); ++ fprintf(stderr, "%s sprintf fail\n", __func__); + } + fileName = buf; + } +@@ -91,14 +91,14 @@ void PluginLog::LogWrite(const char *tag, const char *msg) + { + time_t nowTime = time(nullptr); + if (nowTime == -1) { +- printf("%s fail\n", __func__); ++ fprintf(stderr, "%s fail\n", __func__); + } + struct tm *t = localtime(&nowTime); + char buf[30]; + int ret = sprintf(buf, "%4d-%02d-%02d %02d:%02d:%02d ", t->tm_year + BASE_DATE, t->tm_mon + 1, t->tm_mday, + t->tm_hour, t->tm_min, t->tm_sec); + if (ret < 0) { +- printf("%s sprintf fail\n", __func__); ++ fprintf(stderr, "%s sprintf fail\n", __func__); + } + string stag = tag; + string smsg = msg; +@@ -109,7 +109,7 @@ void PluginLog::LogWrite(const char *tag, const char *msg) + void PluginLog::LogPrint(LogPriority pri, const char *tag, const char *buf) + { + if (pri <= priority) { +- printf("%s%s", tag, buf); ++ fprintf(stderr, "%s%s", tag, buf); + } + + g_mutex.lock(); +@@ -123,7 +123,7 @@ void PluginLog::LOGE(const char *fmt, ...) + va_start(ap, fmt); + int ret = vsnprintf(logBuf, LOG_BUF_SIZE, fmt, ap); + if (ret < 0) { +- printf("%s vsnprintf fail\n", __func__); ++ fprintf(stderr, "%s vsnprintf fail\n", __func__); + } + va_end(ap); + +@@ -136,7 +136,7 @@ void PluginLog::LOGW(const char *fmt, ...) + va_start(ap, fmt); + int ret = vsnprintf(logBuf, LOG_BUF_SIZE, fmt, ap); + if (ret < 0) { +- printf("%s vsnprintf fail\n", __func__); ++ fprintf(stderr, "%s vsnprintf fail\n", __func__); + } + va_end(ap); + LogPrint(PRIORITY_WARN, "WARN:", logBuf); +@@ -148,7 +148,7 @@ void PluginLog::LOGI(const char *fmt, ...) + va_start(ap, fmt); + int ret = vsnprintf(logBuf, LOG_BUF_SIZE, fmt, ap); + if (ret < 0) { +- printf("%s vsnprintf fail\n", __func__); ++ fprintf(stderr, "%s vsnprintf fail\n", __func__); + } + va_end(ap); + LogPrint(PRIORITY_INFO, "INFO:", logBuf); +@@ -160,7 +160,7 @@ void PluginLog::LOGD(const char *fmt, ...) + va_start(ap, fmt); + int ret = vsnprintf(logBuf, LOG_BUF_SIZE, fmt, ap); + if (ret < 0) { +- printf("%s vsnprintf fail\n", __func__); ++ fprintf(stderr, "%s vsnprintf fail\n", __func__); + } + va_end(ap); + LogPrint(PRIORITY_DEBUG, "DEBUG:", logBuf); +diff --git a/user/ArrayWidenPass.cpp b/user/ArrayWidenPass.cpp +index db8223a..475f784 100644 +--- a/user/ArrayWidenPass.cpp ++++ b/user/ArrayWidenPass.cpp +@@ -46,7 +46,7 @@ std::map opNameMap; + + static void PassManagerSetupFunc(void) + { +- printf("PassManagerSetupFunc in\n"); ++ fprintf(stderr, "PassManagerSetupFunc in\n"); + } + + enum EDGE_FLAG { +@@ -878,27 +878,27 @@ static bool checkOriginLoopInfo(LoopOp loop) + static bool checkRecordLoopForm(LoopOp loop) + { + if (!recordOriginLoopExitInfo (loop)) { +- printf ("\nFailed to record loop exit information.\n"); ++ fprintf(stderr, "\nFailed to record loop exit information.\n"); + return false; + } + + if (!recordOriginLoopHeader (loop)) { +- printf ("\nFailed to record loop header information.\n"); ++ fprintf(stderr, "\nFailed to record loop header information.\n"); + return false; + } + + if (!recordOriginLoopLatch (loop)) { +- printf ("\nFailed to record loop latch information.\n"); ++ fprintf(stderr, "\nFailed to record loop latch information.\n"); + return false; + } + + if (!recordOriginLoopBody (loop)) { +- printf ("\nFailed to record loop body information.\n"); ++ fprintf(stderr, "\nFailed to record loop body information.\n"); + return false; + } + + if (!checkOriginLoopInfo (loop)) { +- printf ("\nFailed to check origin loop information.\n"); ++ fprintf(stderr, "\nFailed to check origin loop information.\n"); + return false; + } + +@@ -908,22 +908,22 @@ static bool checkRecordLoopForm(LoopOp loop) + static bool determineLoopForm(LoopOp loop) + { + if (loop.innerLoopIdAttr().getInt() != 0 && loop.numBlockAttr().getInt() != 3) { +- printf ("\nWrong loop form, there is inner loop or redundant bb.\n"); ++ fprintf(stderr, "\nWrong loop form, there is inner loop or redundant bb.\n"); + return false; + } + + if (loop.GetSingleExit().first || !loop.GetLatch()) { +- printf ("\nWrong loop form, only one exit or loop_latch does not exist.\n"); ++ fprintf(stderr, "\nWrong loop form, only one exit or loop_latch does not exist.\n"); + return false; + } + + if (!isLoopSingleBackedge(loop)) { +- printf ("\nWrong loop form, loop back edges are not unique.\n"); ++ fprintf(stderr, "\nWrong loop form, loop back edges are not unique.\n"); + return false; + } + + if (!isLoopSinglePreheaderBB(loop)) { +- printf ("\nWrong loop form, loop preheader bb are not unique.\n"); ++ fprintf(stderr, "\nWrong loop form, loop preheader bb are not unique.\n"); + return false; + } + +@@ -1488,11 +1488,11 @@ static void ProcessArrayWiden(uint64_t fun) + mlir::OpBuilder opBuilder_temp = mlir::OpBuilder(context); + opBuilder = &opBuilder_temp; + string name = funcOp.funcNameAttr().getValue().str(); +- printf("Now process func : %s \n", name.c_str()); ++ fprintf(stderr, "Now process func : %s \n", name.c_str()); + vector allLoop = funcOp.GetAllLoops(); + for (auto &loop : allLoop) { + if (determineLoopForm(loop)) { +- printf("The loop form is success matched, and the loop can be optimized.\n"); ++ fprintf(stderr, "The loop form is success matched, and the loop can be optimized.\n"); + convertToNewLoop(&loop, &funcOp); + } + } +diff --git a/user/LocalVarSummeryPass.cpp b/user/LocalVarSummeryPass.cpp +index 04d4ac9..b7e104e 100755 +--- a/user/LocalVarSummeryPass.cpp ++++ b/user/LocalVarSummeryPass.cpp +@@ -36,38 +36,38 @@ static void LocalVarSummery(void) + map 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); ++ fprintf(stderr, "In the %ldth function:\n", i); + vector decls = pluginAPI.GetDecls(funcID); + int64_t typeFilter = -1u; + if (args.find("type_code") != args.end()) { + typeFilter = (int64_t)pluginAPI.GetTypeCodeFromString(args["type_code"]); + } + mlir::Plugin::FunctionOp funcOp = allFunction[i]; +- printf("func name is :%s\n", funcOp.funcNameAttr().getValue().str().c_str()); ++ fprintf(stderr, "func name is :%s\n", funcOp.funcNameAttr().getValue().str().c_str()); + if (funcOp.validTypeAttr().getValue()) { + mlir::Type dgyty = funcOp.type(); + if (auto ty = dgyty.dyn_cast()) { + if(auto stTy = ty.getReturnType().dyn_cast()) { +- printf("func return type is PluginStructType\n"); ++ fprintf(stderr, "func return type is PluginStructType\n"); + std::string tyName = stTy.getName(); +- printf(" struct name is : %s\n", tyName.c_str()); ++ fprintf(stderr, " struct name is : %s\n", tyName.c_str()); + + llvm::ArrayRef paramsNames = stTy.getElementNames(); + for (auto name :paramsNames) { + std::string pName = name; +- printf("\n struct argname is : %s\n", pName.c_str()); ++ fprintf(stderr, "\n struct argname is : %s\n", pName.c_str()); + } + } + if(auto stTy = ty.getReturnType().dyn_cast()) { +- printf("func return type is PluginVectorType\n"); +- printf(" vector elem num : %d\n", stTy.getNumElements()); +- printf(" vector elem type id : %d\n", stTy.getElementType().dyn_cast().getPluginTypeID()); ++ fprintf(stderr, "func return type is PluginVectorType\n"); ++ fprintf(stderr, " vector elem num : %d\n", stTy.getNumElements()); ++ fprintf(stderr, " vector elem type id : %d\n", stTy.getElementType().dyn_cast().getPluginTypeID()); + } + size_t paramIndex = 0; + llvm::ArrayRef paramsType = ty.getParams(); + for (auto ty : ty.getParams()) { +- printf("\n Param index : %ld\n", paramIndex++); +- printf("\n Param type id : %d\n", ty.dyn_cast().getPluginTypeID()); ++ fprintf(stderr, "\n Param index : %ld\n", paramIndex++); ++ fprintf(stderr, "\n Param type id : %d\n", ty.dyn_cast().getPluginTypeID()); + } + } + } +@@ -76,7 +76,7 @@ static void LocalVarSummery(void) + 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()); ++ fprintf(stderr, "\tFind %ldth target type %s\n", j, name.c_str()); + } + } + } +-- +2.33.0 + diff --git a/pin-server.spec b/pin-server.spec index b980e02b867d702c8e0572de632b0bc5c16fde72..ce8199b3839d377190ae28ec2aca0f296d0069cb 100644 --- a/pin-server.spec +++ b/pin-server.spec @@ -1,6 +1,6 @@ Name: pin-server Version: 0.4.0 -Release: 7 +Release: 8 Summary: Pin (Plug-IN framework) server provides plugin APIs for compiler optimization developers to develop optimization pass. License: Apache 2.0 URL: https://gitee.com/openeuler/pin-server @@ -35,6 +35,7 @@ Patch22: 0022-Pin-server-Add-support-for-decl-and-field-SetDeclNam.patch Patch23: 0023-Pin-server-Add-StructReorderPASS-demo.patch Patch24: 0024-Pin-server-Fix-VectorType.patch Patch25: 0025-Pin-server-Fix-Pass-DoOptimize-method-and-struct-sel.patch +Patch26: 0026-Pin-server-Fix-log-output-form.patch %description Pin (Plug-IN framework) server provides plugin APIs for compiler optimization developers to develop optimization pass. @@ -75,6 +76,7 @@ A demo for pin-server %patch23 -p1 %patch24 -p1 %patch25 -p1 +%patch26 -p1 mkdir -p _build cd _build @@ -115,6 +117,12 @@ find %{_libdir} -type f -name "libMLIRServerAPI.so" -exec strip "{}" ";" %config(noreplace) /etc/ld.so.conf.d/%{name}-%{_arch}.conf %changelog +* Tue Mar 21 2023 dingguangya - 0.4.0-8 +- Type:Update +- ID:NA +- SUG:NA +- DESC:Fix log output form + * Fri Mar 17 2023 dingguangya - 0.4.0-7 - Type:Update - ID:NA