pin-server/0001-Pin-server-Support-for-new-insertion-points-and-new-.patch
benniaobufeijiushiji 43622cf48f [sync] Sync patch from openEuler/pin-server
Sync patch from openEuler/pin-server 20221208

(cherry picked from commit 5b1dfc11cd542269226338319a38315ba6f5cf7e)
2022-12-09 09:52:15 +08:00

86 lines
2.8 KiB
Diff

From 192ac2d7c8568fa5c8f02039707bc951747c877b Mon Sep 17 00:00:00 2001
From: dingguangya <dingguangya1@huawei.com>
Date: Wed, 7 Dec 2022 21:59:02 +0800
Subject: [PATCH 1/4] [Pin-server] Support for new insertion points and new
Pass It supports the phiopt insertion point and provides a simple
arraywiden pass interface.
---
include/PluginServer/PluginServer.h | 1 +
user.cpp | 42 +++++++++++++++++++++++++++--
2 files changed, 41 insertions(+), 2 deletions(-)
diff --git a/include/PluginServer/PluginServer.h b/include/PluginServer/PluginServer.h
index 667cedc..2cb314c 100644
--- a/include/PluginServer/PluginServer.h
+++ b/include/PluginServer/PluginServer.h
@@ -79,6 +79,7 @@ enum InjectPoint : uint8_t {
// 参考点名称
enum RefPassName {
PASS_CFG,
+ PASS_PHIOPT,
PASS_SSA,
PASS_LOOP,
};
diff --git a/user.cpp b/user.cpp
index 50fc3bb..81958c0 100644
--- a/user.cpp
+++ b/user.cpp
@@ -77,13 +77,51 @@ static void PassManagerSetupFunc(void)
printf("PassManagerSetupFunc in\n");
}
+static bool
+determineLoopForm(LoopOp loop)
+{
+ if (loop.innerLoopIdAttr().getUInt() != 0 || loop.numBlockAttr().getUInt() != 3)
+ {
+ printf ("\nWrong loop form, there is inner loop or redundant bb.\n");
+ return false;
+ }
+
+ if (loop.GetSingleExit().first != 0 || !loop.GetLatch())
+ {
+ printf ("\nWrong loop form, only one exit or loop_latch does not exist.\n");
+ return false;
+ }
+ return true;
+}
+
+static void
+ProcessArrayWiden(void)
+{
+ std::cout << "Running first pass, OMG\n";
+
+ PluginServerAPI pluginAPI;
+ vector<FunctionOp> allFunction = pluginAPI.GetAllFunc();
+
+ for (auto &funcOp : allFunction) {
+ string name = funcOp.funcNameAttr().getValue().str();
+ printf("Now process func : %s \n", name.c_str());
+ vector<LoopOp> allLoop = funcOp.GetAllLoops();
+ for (auto &loop : allLoop) {
+ if (determineLoopForm(loop)) {
+ printf("The %dth loop form is success matched, and the loop can be optimized.\n", loop.indexAttr().getUInt());
+ return;
+ }
+ }
+ }
+}
+
void RegisterCallbacks(void)
{
PluginServer::GetInstance()->RegisterUserFunc(HANDLE_BEFORE_IPA, UserOptimizeFunc);
PluginServer::GetInstance()->RegisterUserFunc(HANDLE_BEFORE_IPA, LocalVarSummery);
ManagerSetupData setupData;
- setupData.refPassName = PASS_CFG;
+ setupData.refPassName = PASS_PHIOPT;
setupData.passNum = 1;
setupData.passPosition = PASS_INSERT_AFTER;
- PluginServer::GetInstance()->RegisterPassManagerSetup(HANDLE_MANAGER_SETUP, setupData, PassManagerSetupFunc);
+ PluginServer::GetInstance()->RegisterPassManagerSetup(HANDLE_MANAGER_SETUP, setupData, ProcessArrayWiden);
}
--
2.27.0.windows.1