Compare commits

...

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
95ab8f9ce7
!56 [Sync] Sync patch from openeuler/pin-gcc-client
From: @dguangya 
Reviewed-by: @wumingchuan 
Signed-off-by: @wumingchuan
2023-09-19 07:00:38 +00:00
dingguangya
8c8f013cae [Sync] Sync patch from openeuler/pin-gcc-client 2023-09-19 11:03:33 +08:00
openeuler-ci-bot
20585f562b
!49 modify %patchxxx -p1 to %autosetup -p1
From: @BowenShen 
Reviewed-by: @wumingchuan 
Signed-off-by: @wumingchuan
2023-05-18 07:05:41 +00:00
shenbowen
39414ea2db modify %patchxxx -p1 to %autosetup -p1
Signed-off-by: shenbowen <shenbowen@xfusion.com>
(cherry picked from commit 9348d50a510d0d3b4282720ee41099ffab9455f8)
2023-05-09 12:32:14 +08:00
openeuler-ci-bot
36293b2765
!45 [sync] PR-44: [Update] Fix the bug during multi-process compilation
From: @openeuler-sync-bot 
Reviewed-by: @wumingchuan 
Signed-off-by: @wumingchuan
2023-04-06 11:34:47 +00:00
dingguangya
cdfe23207e [Update] Fix the bug during multi-process compilation
(cherry picked from commit 35567be976a30081271e3fdcd32ec6716e1df0d1)
2023-04-06 16:51:21 +08:00
openeuler-ci-bot
66aaca8f8b
!42 [sync] PR-40: [Update] Fix TreeToValue-VAR_DECL and ARRAY_TYPE-getDomainIndex
From: @openeuler-sync-bot 
Reviewed-by: @li-yancheng 
Signed-off-by: @li-yancheng
2023-03-26 11:09:02 +00:00
dingguangya
0c88ed1264 [Update] Fix TreeToValue-VAR_DECL and ARRAY_TYPE-getDomainIndex
(cherry picked from commit 89dacd7371f4bbef6320a883920b31426395eec8)
2023-03-26 16:52:20 +08:00
openeuler-ci-bot
5cfb367bb0
!38 [sync] PR-36: [Update] Fix VectorType CallOp TreeTOValue
From: @openeuler-sync-bot 
Reviewed-by: @eastb233 
Signed-off-by: @eastb233
2023-03-20 02:24:15 +00:00
dingguangya
8244116eba [Update] Fix VectorType CallOp TreeTOValue
(cherry picked from commit bbc0161b42734690091e017646180d9302b9e296)
2023-03-19 13:34:42 +08:00
7 changed files with 784 additions and 9 deletions

View File

@ -0,0 +1,35 @@
From 1627b093a630df63ecdf93d198ef3806e757d4db Mon Sep 17 00:00:00 2001
From: d00573793 <dingguangya1@huawei.com>
Date: Thu, 9 Mar 2023 16:00:02 +0800
Subject: [PATCH] [Pin-gcc-client] Fix VectorType
diff --git a/lib/Dialect/PluginTypes.cpp b/lib/Dialect/PluginTypes.cpp
index 58ee68e..1b3e09a 100644
--- a/lib/Dialect/PluginTypes.cpp
+++ b/lib/Dialect/PluginTypes.cpp
@@ -418,7 +418,7 @@ unsigned PluginArrayType::getNumElements()
PluginTypeID PluginVectorType::getPluginTypeID()
{
- return PluginTypeID::ArrayTyID;
+ return PluginTypeID::VectorTyID;
}
bool PluginVectorType::isValidElementType(Type type)
diff --git a/lib/Translate/TypeTranslation.cpp b/lib/Translate/TypeTranslation.cpp
index 458d5a3..354a8b9 100644
--- a/lib/Translate/TypeTranslation.cpp
+++ b/lib/Translate/TypeTranslation.cpp
@@ -176,7 +176,7 @@ private:
if (TREE_CODE(type) == ARRAY_TYPE)
return PluginArrayType::get(&context,translatePrimitiveType(TREE_TYPE(type)), getDomainIndex(type));
if (TREE_CODE(type) == VECTOR_TYPE)
- return PluginArrayType::get(&context,translatePrimitiveType(TREE_TYPE(type)), getElemNum(type));
+ return PluginVectorType::get(&context,translatePrimitiveType(TREE_TYPE(type)), getElemNum(type));
if (TREE_CODE(type) == FUNCTION_TYPE) {
llvm::SmallVector<Type> argsType = getArgsType(type);
return PluginFunctionType::get(&context, translatePrimitiveType(TREE_TYPE(type)),argsType);
--
2.33.0

View File

@ -0,0 +1,367 @@
From 7879456e9645e34cf1bcc61ad340834ba1ac716a Mon Sep 17 00:00:00 2001
From: d00573793 <dingguangya1@huawei.com>
Date: Fri, 17 Mar 2023 10:27:41 +0800
Subject: [PATCH] [Pin-gcc-client] Fix struct self-contained CallOp TreeTOValue
diff --git a/include/Dialect/PluginOps.td b/include/Dialect/PluginOps.td
index 143a856..ba29f7e 100644
--- a/include/Dialect/PluginOps.td
+++ b/include/Dialect/PluginOps.td
@@ -56,14 +56,16 @@ def FunctionOp : Plugin_Op<"function", [NoSideEffect]> {
let arguments = (ins UI64Attr:$id,
StrAttr:$funcName,
OptionalAttr<BoolAttr>:$declaredInline,
- TypeAttr:$type);
+ TypeAttr:$type,
+ OptionalAttr<BoolAttr>:$validType);
let regions = (region AnyRegion:$bodyRegion);
// Add custom build methods for the operation. These method populates
// the `state` that MLIR uses to create operations, i.e. these are used when
// using `builder.create<Op>(...)`.
let builders = [
- OpBuilderDAG<(ins "uint64_t":$id, "StringRef":$funcName, "bool":$declaredInline, "Type":$type)>
+ OpBuilderDAG<(ins "uint64_t":$id, "StringRef":$funcName, "bool":$declaredInline, "Type":$type, "bool":$validType)>,
+ OpBuilderDAG<(ins "uint64_t":$id, "StringRef":$funcName, "bool":$declaredInline, "bool":$validType)>
];
let extraClassDeclaration = [{
Type getResultType();
diff --git a/include/Dialect/PluginTypes.h b/include/Dialect/PluginTypes.h
index 983d7ca..081b35b 100644
--- a/include/Dialect/PluginTypes.h
+++ b/include/Dialect/PluginTypes.h
@@ -191,12 +191,10 @@ public:
static bool isValidElementType(Type type);
- static PluginStructType get(MLIRContext *context, StringRef name, ArrayRef<Type> elements, ArrayRef<StringRef> elemNames);
+ static PluginStructType get(MLIRContext *context, StringRef name, ArrayRef<StringRef> elemNames);
StringRef getName();
- ArrayRef<Type> getBody();
-
ArrayRef<StringRef> getElementNames();
}; // class PluginStructType
diff --git a/lib/Dialect/PluginOps.cpp b/lib/Dialect/PluginOps.cpp
index cf1dbbe..ec8286a 100644
--- a/lib/Dialect/PluginOps.cpp
+++ b/lib/Dialect/PluginOps.cpp
@@ -49,15 +49,26 @@ void CGnodeOp::build(OpBuilder &builder, OperationState &state,
// ============================
void FunctionOp::build(OpBuilder &builder, OperationState &state,
- uint64_t id, StringRef funcName, bool declaredInline, Type type)
+ uint64_t id, StringRef funcName, bool declaredInline, Type type, bool validType)
{
state.addRegion();
state.addAttribute("id", builder.getI64IntegerAttr(id));
state.addAttribute("funcName", builder.getStringAttr(funcName));
state.addAttribute("declaredInline", builder.getBoolAttr(declaredInline));
+ state.addAttribute("validType", builder.getBoolAttr(validType));
if (type) state.addAttribute("type", TypeAttr::get(type));
}
+void FunctionOp::build(OpBuilder &builder, OperationState &state,
+ uint64_t id, StringRef funcName, bool declaredInline, bool validType)
+{
+ state.addRegion();
+ state.addAttribute("id", builder.getI64IntegerAttr(id));
+ state.addAttribute("funcName", builder.getStringAttr(funcName));
+ state.addAttribute("declaredInline", builder.getBoolAttr(declaredInline));
+ state.addAttribute("validType", builder.getBoolAttr(validType));
+}
+
Type FunctionOp::getResultType()
{
PluginIR::PluginFunctionType resultType = type().dyn_cast<PluginIR::PluginFunctionType>();
diff --git a/lib/Dialect/PluginTypes.cpp b/lib/Dialect/PluginTypes.cpp
index 1b3e09a..6c5cb0c 100644
--- a/lib/Dialect/PluginTypes.cpp
+++ b/lib/Dialect/PluginTypes.cpp
@@ -147,29 +147,28 @@ namespace Detail {
};
struct PluginStructTypeStorage : public TypeStorage {
- using KeyTy = std::tuple<StringRef, ArrayRef<Type>, ArrayRef<StringRef>>;
+ using KeyTy = std::tuple<StringRef, ArrayRef<StringRef>>;
- PluginStructTypeStorage(StringRef name, ArrayRef<Type> elements, ArrayRef<StringRef> elemNames)
- : name(name), elements(elements), elemNames(elemNames) {}
+ PluginStructTypeStorage(StringRef name, ArrayRef<StringRef> elemNames)
+ : name(name), elemNames(elemNames) {}
static PluginStructTypeStorage *construct(TypeStorageAllocator &allocator, KeyTy key)
{
return new (allocator.allocate<PluginStructTypeStorage>())
- PluginStructTypeStorage(std::get<0>(key), allocator.copyInto(std::get<1>(key)), allocator.copyInto(std::get<2>(key)));
+ PluginStructTypeStorage(std::get<0>(key), allocator.copyInto(std::get<1>(key)));
}
static unsigned hashKey(const KeyTy &key) {
// LLVM doesn't like hashing bools in tuples.
- return llvm::hash_combine(std::get<0>(key), std::get<1>(key), std::get<2>(key));
+ return llvm::hash_combine(std::get<0>(key), std::get<1>(key));
}
bool operator==(const KeyTy &key) const
{
- return std::make_tuple(name, elements, elemNames) == key;
+ return std::make_tuple(name, elemNames) == key;
}
StringRef name;
- ArrayRef<Type> elements;
ArrayRef<StringRef> elemNames;
};
} // namespace Detail
@@ -496,9 +495,9 @@ bool PluginStructType::isValidElementType(Type type) {
return !type.isa<PluginVoidType, PluginFunctionType>();
}
-PluginStructType PluginStructType::get(MLIRContext *context, StringRef name, ArrayRef<Type> elements, ArrayRef<StringRef> elemNames)
+PluginStructType PluginStructType::get(MLIRContext *context, StringRef name, ArrayRef<StringRef> elemNames)
{
- return Base::get(context, name, elements, elemNames);
+ return Base::get(context, name, elemNames);
}
StringRef PluginStructType::getName()
@@ -506,11 +505,6 @@ StringRef PluginStructType::getName()
return getImpl()->name;
}
-ArrayRef<Type> PluginStructType::getBody()
-{
- return getImpl()->elements;
-}
-
ArrayRef<StringRef> PluginStructType::getElementNames()
{
return getImpl()->elemNames;
diff --git a/lib/PluginClient/PluginJson.cpp b/lib/PluginClient/PluginJson.cpp
index be0ee8d..7384a49 100755
--- a/lib/PluginClient/PluginJson.cpp
+++ b/lib/PluginClient/PluginJson.cpp
@@ -53,12 +53,6 @@ Json::Value PluginJson::TypeJsonSerialize(PluginIR::PluginTypeBase type)
std::string tyName = Ty.getName().str();
item["structtype"] = tyName;
size_t paramIndex = 0;
- ArrayRef<Type> paramsType = Ty.getBody();
- for (auto ty :paramsType) {
- string paramStr = "elemType" + std::to_string(paramIndex++);
- item["structelemType"][paramStr] = TypeJsonSerialize(ty.dyn_cast<PluginIR::PluginTypeBase>());
- }
- paramIndex = 0;
ArrayRef<StringRef> paramsNames = Ty.getElementNames();
for (auto name :paramsNames) {
string paramStr = "elemName" + std::to_string(paramIndex++);
@@ -164,21 +158,14 @@ PluginIR::PluginTypeBase PluginJson::TypeJsonDeSerialize(const string& data, mli
baseType = PluginIR::PluginFunctionType::get(&context, returnTy, typelist);
} else if (id == static_cast<uint64_t>(PluginIR::StructTyID)) {
StringRef tyName = type["structtype"].toStyledString();
- llvm::SmallVector<Type> typelist;
- Json::Value::Members elemTypeNum = type["structelemType"].getMemberNames();
- for (size_t paramIndex = 0; paramIndex < elemTypeNum.size(); paramIndex++) {
- string Key = "elemType" + std::to_string(paramIndex);
- mlir::Type paramTy = TypeJsonDeSerialize(type["structelemType"][Key].toStyledString(), context);
- typelist.push_back(paramTy);
- }
llvm::SmallVector<StringRef> names;
Json::Value::Members elemNameNum = type["structelemName"].getMemberNames();
- for (size_t paramIndex = 0; paramIndex < elemTypeNum.size(); paramIndex++) {
+ for (size_t paramIndex = 0; paramIndex < elemNameNum.size(); paramIndex++) {
string Key = "elemName" + std::to_string(paramIndex);
StringRef elemName = type["structelemName"][Key].toStyledString();
names.push_back(elemName);
}
- baseType = PluginIR::PluginStructType::get(&context, tyName, typelist, names);
+ baseType = PluginIR::PluginStructType::get(&context, tyName, names);
}
else {
if (PluginTypeId == PluginIR::VoidTyID) {
@@ -229,11 +216,16 @@ void PluginJson::FunctionOpJsonSerialize(vector<FunctionOp>& data, string& out)
}
item["attributes"]["funcName"] = d.funcNameAttr().getValue().str().c_str();
- mlir::Type fnty = d.type();
- if (auto ty = fnty.dyn_cast<PluginIR::PluginFunctionType>()) {
- if (auto retTy = ty.dyn_cast<PluginIR::PluginTypeBase>()) {
- item["retType"] = TypeJsonSerialize(retTy);
+ if (d.validTypeAttr().getValue()) {
+ item["attributes"]["validType"] = "1";
+ mlir::Type fnty = d.type();
+ if (auto ty = fnty.dyn_cast<PluginIR::PluginFunctionType>()) {
+ if (auto retTy = ty.dyn_cast<PluginIR::PluginTypeBase>()) {
+ item["retType"] = TypeJsonSerialize(retTy);
+ }
}
+ } else {
+ item["attributes"]["validType"] = "0";
}
auto &region = d.getRegion();
diff --git a/lib/Translate/GimpleToPluginOps.cpp b/lib/Translate/GimpleToPluginOps.cpp
index 930b430..d1b8319 100644
--- a/lib/Translate/GimpleToPluginOps.cpp
+++ b/lib/Translate/GimpleToPluginOps.cpp
@@ -379,6 +379,9 @@ vector<uint64_t> GimpleToPluginOps::GetFunctionIDs()
function *fn = NULL;
vector<uint64_t> functions;
FOR_EACH_FUNCTION (node) {
+ if (!node->real_symbol_p ())
+ continue;
+ if(!node->definition) continue;
fn = DECL_STRUCT_FUNCTION(node->decl);
if (fn == NULL)
continue;
@@ -820,12 +823,20 @@ FunctionOp GimpleToPluginOps::BuildFunctionOp(uint64_t functionId)
bool declaredInline = false;
if (DECL_DECLARED_INLINE_P(fn->decl))
declaredInline = true;
- tree returnType = TREE_TYPE(fn->decl);
- PluginTypeBase rPluginType = typeTranslator.translateType((intptr_t)returnType);
auto location = builder.getUnknownLoc();
- auto Ty = rPluginType.dyn_cast<PluginFunctionType>();
- FunctionOp retOp = builder.create<FunctionOp>(location, functionId,
- funcName, declaredInline, Ty);
+ bool validType = false;
+ tree returnType = TREE_TYPE(fn->decl);
+ FunctionOp retOp;
+ if (TREE_CODE(returnType) != FUNCTION_TYPE) {
+ retOp = builder.create<FunctionOp>(location, functionId,
+ funcName, declaredInline, validType);
+ } else {
+ validType = true;
+ PluginTypeBase rPluginType = typeTranslator.translateType((intptr_t)returnType);
+ auto Ty = rPluginType.dyn_cast<PluginFunctionType>();
+ retOp = builder.create<FunctionOp>(location, functionId,
+ funcName, declaredInline, Ty, validType);
+ }
auto& fr = retOp.bodyRegion();
if (fn->cfg == nullptr) return retOp;
if (!ProcessBasicBlock((intptr_t)ENTRY_BLOCK_PTR_FOR_FN(fn), fr)) {
@@ -1000,8 +1011,13 @@ CallOp GimpleToPluginOps::BuildCallOp(uint64_t gcallId)
Value arg = TreeToValue(argId);
ops.push_back(arg);
}
- tree returnType = gimple_call_return_type(stmt);
- PluginTypeBase rPluginType = typeTranslator.translateType((intptr_t)returnType);
+ // tree returnType = gimple_call_return_type(stmt);
+ // PluginTypeBase rPluginType = typeTranslator.translateType((intptr_t)returnType);
+ PluginTypeBase rPluginType = nullptr;
+ if (gimple_call_fntype (stmt) != NULL_TREE || gimple_call_lhs (stmt) != NULL_TREE) {
+ tree returnType = gimple_call_return_type(stmt);
+ rPluginType = typeTranslator.translateType((intptr_t)returnType);
+ }
tree fndecl = gimple_call_fndecl(stmt);
CallOp ret;
if (fndecl == NULL_TREE || DECL_NAME(fndecl) == NULL_TREE) {
@@ -1665,6 +1681,12 @@ Value GimpleToPluginOps::TreeToValue(uint64_t treeId)
break;
}
case BLOCK : {
+ if (BLOCK_VARS(t) == NULL_TREE) {
+ GetTreeAttr(treeId, readOnly, rPluginType);
+ opValue = builder.create<PlaceholderOp>(builder.getUnknownLoc(),
+ treeId, IDefineCode::UNDEF, readOnly, rPluginType);
+ break;
+ }
llvm::Optional<mlir::Value> vars = TreeToValue((uint64_t)BLOCK_VARS(t));
llvm::Optional<uint64_t> supercontext = (uint64_t)BLOCK_SUPERCONTEXT(t);
llvm::Optional<mlir::Value> subblocks = TreeToValue((uint64_t)BLOCK_SUBBLOCKS(t));
@@ -1746,7 +1768,9 @@ bool GimpleToPluginOps::ProcessGimpleStmt(intptr_t bbPtr, Region& rg)
// Process other condition, such as return
builder.create<RetOp>(builder.getUnknownLoc(), (uint64_t)bb);
} else {
- assert(false);
+ builder.create<FallThroughOp>(builder.getUnknownLoc(), (uint64_t)bb,
+ bbTranslator->blockMaps[EDGE_SUCC(bb, 0)->dest],
+ (uint64_t)(EDGE_SUCC(bb, 0)->dest));
}
}
diff --git a/lib/Translate/TypeTranslation.cpp b/lib/Translate/TypeTranslation.cpp
index 354a8b9..8a0a674 100644
--- a/lib/Translate/TypeTranslation.cpp
+++ b/lib/Translate/TypeTranslation.cpp
@@ -130,6 +130,8 @@ private:
llvm::SmallVector<Type> getElemType(tree type)
{
llvm::SmallVector<Type> typelist;
+ if (!type)
+ return typelist;
tree parmtype;
for (tree field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
{
@@ -145,6 +147,8 @@ private:
llvm::SmallVector<StringRef> getElemNames(tree type)
{
llvm::SmallVector<StringRef> names;
+ if (!type)
+ return names;
StringRef name;
for (tree field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
{
@@ -161,6 +165,8 @@ private:
type. */
PluginTypeBase translatePrimitiveType (tree type)
{
+ if (!type)
+ return PluginUndefType::get(&context);
if (TREE_CODE(type) == INTEGER_TYPE)
return PluginIntegerType::get(&context, getBitWidth(type),
isUnsigned(type) ? PluginIntegerType::Unsigned : PluginIntegerType::Signed);
@@ -170,9 +176,10 @@ private:
return PluginBooleanType::get(&context);
if (TREE_CODE(type) == VOID_TYPE)
return PluginVoidType::get(&context);
- if (TREE_CODE(type) == POINTER_TYPE)
+ if (TREE_CODE(type) == POINTER_TYPE) {
return PluginPointerType::get(&context, translatePrimitiveType(TREE_TYPE(type)),
TYPE_READONLY(TREE_TYPE(type)) ? 1 : 0);
+ }
if (TREE_CODE(type) == ARRAY_TYPE)
return PluginArrayType::get(&context,translatePrimitiveType(TREE_TYPE(type)), getDomainIndex(type));
if (TREE_CODE(type) == VECTOR_TYPE)
@@ -182,7 +189,7 @@ private:
return PluginFunctionType::get(&context, translatePrimitiveType(TREE_TYPE(type)),argsType);
}
if (TREE_CODE(type) == RECORD_TYPE) {
- return PluginStructType::get(&context, getTypeName(type), getElemType(type), getElemNames(type));
+ return PluginStructType::get(&context, getTypeName(type), getElemNames(type));
}
return PluginUndefType::get(&context);
}
@@ -295,7 +302,6 @@ private:
return build_function_type_array(returnType, paramTypes.length (), paramTypes.address ());
}
if (auto Ty = type.dyn_cast<PluginStructType>()) {
- ArrayRef<Type> elemTypes = Ty.getBody();
ArrayRef<StringRef> elemNames = Ty.getElementNames();
StringRef tyName = Ty.getName();
unsigned fieldSize = elemNames.size();
@@ -305,18 +311,8 @@ private:
unsigned i;
ret = make_node (RECORD_TYPE);
- for (i = 0; i < fieldSize; i++)
- {
- mlir::Type elemTy = elemTypes[i];
- auto ty = elemTy.dyn_cast<PluginTypeBase>();
- tree elmType = translatePrimitiveType(ty);
- fields[i] = build_decl (UNKNOWN_LOCATION, FIELD_DECL, get_identifier (elemNames[i].str().c_str()), elmType);
- DECL_CONTEXT (fields[i]) = ret;
- if (i) DECL_CHAIN (fields[i - 1]) = fields[i];
- }
tree typeDecl = build_decl (input_location, TYPE_DECL, get_identifier (tyName.str().c_str()), ret);
DECL_ARTIFICIAL (typeDecl) = 1;
- TYPE_FIELDS (ret) = fields[0];
TYPE_NAME (ret) = typeDecl;
layout_type (ret);
return ret;
--
2.33.0

View File

@ -0,0 +1,41 @@
From 1a2836f9dcd00d8666acf33cbbf0ba58c821676b Mon Sep 17 00:00:00 2001
From: d00573793 <dingguangya1@huawei.com>
Date: Fri, 24 Mar 2023 17:35:51 +0800
Subject: [PATCH] [Pin-gcc-client] Fix TreeToValue-VAR_DECL and
ARRAY_TYPE-getDomainIndex
diff --git a/lib/Translate/GimpleToPluginOps.cpp b/lib/Translate/GimpleToPluginOps.cpp
index d1b8319..80d4e87 100644
--- a/lib/Translate/GimpleToPluginOps.cpp
+++ b/lib/Translate/GimpleToPluginOps.cpp
@@ -1601,7 +1601,9 @@ Value GimpleToPluginOps::TreeToValue(uint64_t treeId)
bool addressable = TREE_ADDRESSABLE(t);
bool used = TREE_USED(t);
int32_t uid = DECL_UID(t);
- mlir::Value initial = TreeToValue((uint64_t)DECL_INITIAL(t));
+ // Fixme: DECL_INITIAL(t) This function causes a memory access error after repeated TreeToValue iterations.
+ // postgresql-11.3 ICE
+ mlir::Value initial = builder.create<PlaceholderOp>(builder.getUnknownLoc(), 0, IDefineCode::UNDEF, 0, rPluginType);
mlir::Value name = TreeToValue((uint64_t)DECL_NAME(t));
llvm::Optional<uint64_t> chain = (uint64_t)DECL_CHAIN(t);
GetTreeAttr(treeId, readOnly, rPluginType);
diff --git a/lib/Translate/TypeTranslation.cpp b/lib/Translate/TypeTranslation.cpp
index 8a0a674..e18f7f5 100644
--- a/lib/Translate/TypeTranslation.cpp
+++ b/lib/Translate/TypeTranslation.cpp
@@ -81,7 +81,10 @@ private:
unsigned getDomainIndex (tree type)
{
- if (TYPE_DOMAIN(type) && TYPE_MAX_VALUE(TYPE_DOMAIN(type)))
+ if (TYPE_DOMAIN(type) && TYPE_MAX_VALUE(TYPE_DOMAIN(type))
+ && TYPE_MIN_VALUE(TYPE_DOMAIN(type))
+ && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (type))) == INTEGER_CST
+ && TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (type))) == INTEGER_CST)
return tree_to_shwi(TYPE_MAX_VALUE(TYPE_DOMAIN(type)))+1;
return 0;
}
--
2.33.0

View File

@ -0,0 +1,50 @@
From 87821c34287af363d40624f75f82ef267828d815 Mon Sep 17 00:00:00 2001
From: Mingchuan Wu <wumingchuan1992@foxmail.com>
Date: Mon, 3 Apr 2023 19:29:16 +0800
Subject: [PATCH] [PluginClient] Fix the bug during multi-process compilation.
diff --git a/lib/PluginClient/PluginClient.cpp b/lib/PluginClient/PluginClient.cpp
index c354d7e..c9f3cb7 100644
--- a/lib/PluginClient/PluginClient.cpp
+++ b/lib/PluginClient/PluginClient.cpp
@@ -28,7 +28,7 @@
namespace PinClient {
using namespace mlir::Plugin;
using namespace mlir;
-static PluginClient g_plugin;
+static PluginClient *g_plugin;
std::map<InjectPoint, plugin_event> g_injectPoint {
{HANDLE_PARSE_TYPE, PLUGIN_FINISH_TYPE},
@@ -47,7 +47,10 @@ std::map<InjectPoint, plugin_event> g_injectPoint {
PluginClient *PluginClient::GetInstance()
{
- return &g_plugin;
+ if (g_plugin == nullptr) {
+ g_plugin = new PluginClient();
+ }
+ return g_plugin;
}
int PluginClient::GetEvent(InjectPoint inject, plugin_event *event)
diff --git a/lib/PluginClient/PluginInputCheck.cpp b/lib/PluginClient/PluginInputCheck.cpp
index 36ebd8c..f2505ca 100755
--- a/lib/PluginClient/PluginInputCheck.cpp
+++ b/lib/PluginClient/PluginInputCheck.cpp
@@ -43,6 +43,11 @@ bool PluginInputCheck::ReadConfigfile(Json::Value& root)
Json::Reader reader;
std::ifstream ifs(configFilePath.c_str());
if (!ifs.is_open()) {
+ if (serverPath == "") {
+ LOGW("open %s fail and server path is NULL! should specify server path first!\n", configFilePath.c_str());
+ } else {
+ LOGW("open %s fail! use default sha256file:%s\n", configFilePath.c_str(), shaPath.c_str());
+ }
return false;
}
--
2.33.0

View File

@ -0,0 +1,37 @@
From 767bc6e10b7286ba22a2a1c0129d978abf094d44 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=83=91=E6=99=A8=E5=8D=89?= <zhengchenhui1@huawei.com>
Date: Thu, 7 Sep 2023 10:52:04 +0800
Subject: [PATCH 1/2] Fix BUILD errors
---
CMakeLists.txt | 1 +
lib/PluginClient/PluginLog.cpp | 1 +
2 files changed, 2 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fcd737b..a0df8c8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -33,6 +33,7 @@ include(TableGen)
include(AddLLVM)
include(AddMLIR)
+include_directories(${GRPC_INCLUDE_DIR})
include_directories(${LLVM_INCLUDE_DIRS})
include_directories(${MLIR_INCLUDE_DIRS})
include_directories(${PROJECT_SOURCE_DIR}/include)
diff --git a/lib/PluginClient/PluginLog.cpp b/lib/PluginClient/PluginLog.cpp
index 7ace548..c9320a5 100644
--- a/lib/PluginClient/PluginLog.cpp
+++ b/lib/PluginClient/PluginLog.cpp
@@ -27,6 +27,7 @@
#include <memory>
#include <mutex>
#include <csignal>
+#include <unistd.h>
#include "PluginClient/PluginLog.h"
namespace PinClient {
--
2.33.0

View File

@ -0,0 +1,216 @@
From b622cc8d95f4ef8bd417d94974e9ff83104beab9 Mon Sep 17 00:00:00 2001
From: Mingchuan Wu <wumingchuan1992@foxmail.com>
Date: Sat, 2 Sep 2023 15:59:19 +0800
Subject: [PATCH 2/2] [PluginClient] Update transfer command.
---
include/PluginAPI/BasicPluginOpsAPI.h | 1 +
include/PluginAPI/PluginClientAPI.h | 1 +
lib/PluginAPI/PluginClientAPI.cpp | 3 ++
lib/PluginClient/PluginClient.cpp | 78 +++++++++++++++++++++++++--
lib/Translate/GimpleToPluginOps.cpp | 11 ++--
5 files changed, 87 insertions(+), 7 deletions(-)
diff --git a/include/PluginAPI/BasicPluginOpsAPI.h b/include/PluginAPI/BasicPluginOpsAPI.h
index 22da8df..37bd73d 100644
--- a/include/PluginAPI/BasicPluginOpsAPI.h
+++ b/include/PluginAPI/BasicPluginOpsAPI.h
@@ -48,6 +48,7 @@ public:
virtual string FuncName(int64_t gccDataAddr) = 0;
virtual int GetDeclSourceLine(uint64_t gccDataAddr) = 0;
virtual int GetDeclSourceColumn(uint64_t gccDataAddr) = 0;
+ virtual void ShutdownCompile() = 0;
// CGnode
virtual vector<uint64_t> GetCGnodeIDs() = 0;
diff --git a/include/PluginAPI/PluginClientAPI.h b/include/PluginAPI/PluginClientAPI.h
index 26ef71d..43e7154 100644
--- a/include/PluginAPI/PluginClientAPI.h
+++ b/include/PluginAPI/PluginClientAPI.h
@@ -38,6 +38,7 @@ public:
string FuncName(int64_t gccDataAddr) override;
int GetDeclSourceLine(uint64_t gccDataAddr) override;
int GetDeclSourceColumn(uint64_t gccDataAddr) override;
+ void ShutdownCompile() override;
uint64_t CreateBlock(uint64_t, uint64_t) override;
void DeleteBlock(uint64_t, uint64_t) override;
diff --git a/lib/PluginAPI/PluginClientAPI.cpp b/lib/PluginAPI/PluginClientAPI.cpp
index 95e9ab3..55f46f7 100644
--- a/lib/PluginAPI/PluginClientAPI.cpp
+++ b/lib/PluginAPI/PluginClientAPI.cpp
@@ -17,6 +17,7 @@
*/
#include "PluginAPI/PluginClientAPI.h"
+#include <unistd.h>
namespace PluginAPI {
@@ -92,6 +93,8 @@ vector<FunctionOp> PluginClientAPI::GetAllFunc()
return gimpleConversion.GetAllFunction();
}
+void PluginClientAPI::ShutdownCompile() { _exit(0); }
+
vector<uint64_t> PluginClientAPI::GetFunctions()
{
return gimpleConversion.GetFunctionIDs();
diff --git a/lib/PluginClient/PluginClient.cpp b/lib/PluginClient/PluginClient.cpp
index c9f3cb7..cf3036d 100644
--- a/lib/PluginClient/PluginClient.cpp
+++ b/lib/PluginClient/PluginClient.cpp
@@ -25,6 +25,10 @@
#include "Dialect/PluginTypes.h"
#include "PluginAPI/PluginClientAPI.h"
+#include "gcc-plugin.h"
+#include "plugin-version.h"
+#include "toplev.h"
+#include "opts.h"
namespace PinClient {
using namespace mlir::Plugin;
using namespace mlir;
@@ -344,6 +348,16 @@ void SetDeclAlignResult(PluginClient *client, Json::Value& root, string& result)
client->ReceiveSendMsg("VoidResult", result);
}
+void ShutdownCompile(PluginClient *client, Json::Value& root, string& result)
+{
+ // Load our Dialect in this MLIR Context.
+ mlir::MLIRContext context;
+ context.getOrLoadDialect<PluginDialect>();
+ PluginAPI::PluginClientAPI clientAPI(context);
+ clientAPI.ShutdownCompile();
+ client->ReceiveSendMsg("VoidResult", result);
+}
+
void SetUserAlignResult(PluginClient *client, Json::Value& root, string& result)
{
/// Json格式
@@ -1335,6 +1349,7 @@ std::map<string, GetResultFunc> g_getResultFunc = {
{"IsDomInfoAvailable", IsDomInfoAvailableResult},
{"GetCurrentDefFromSSA", GetCurrentDefFromSSAResult},
{"SetCurrentDefInSSA", SetCurrentDefInSSAResult},
+ {"ShutdownCompile", ShutdownCompile},
{"CopySSAOp", CopySSAOpResult},
{"CreateSSAOp", CreateSSAOpResult},
{"CreateNewDef", CreateNewDefResult},
@@ -1543,7 +1558,12 @@ static bool WaitServer(const string& port)
mode_t mask = umask(0);
mode_t mode = 0666; // 权限是rwrwrw跨进程时其他用户也要可以访问
string semFile = "wait_server_startup" + port;
- sem_t *sem = sem_open(semFile.c_str(), O_CREAT, mode, 0);
+ sem_t *sem = sem_open(semFile.c_str(), O_CREAT | O_EXCL, mode, 0);
+ // Semaphore exception handling.
+ if (sem == SEM_FAILED) {
+ sem_unlink(semFile.c_str());
+ sem = sem_open(semFile.c_str(), O_CREAT, mode, 0);
+ }
umask(mask);
int i = 0;
for (; i < cnt; i++) {
@@ -1561,11 +1581,60 @@ static bool WaitServer(const string& port)
return true;
}
+bool ExecuteWithCommand(string serverPath, string port, string level)
+{
+ string inputFile (main_input_filename);
+ string cwd = get_current_dir_name();
+
+ string outputName="";
+ for (int i = 0; i< save_decoded_options_count; ++i) {
+ if (!strcmp(save_decoded_options[i].canonical_option[0],"-o")) {
+ outputName = save_decoded_options[i].canonical_option[1];
+ }
+ }
+
+ string common_opt = "";
+ for (int i = 0; i< save_decoded_options_count; ++i) {
+ if (!strcmp(save_decoded_options[i].canonical_option[0],"-I") ||
+ !strcmp(save_decoded_options[i].canonical_option[0],"-D")) {
+ common_opt.append(save_decoded_options[i].canonical_option[0]);
+ common_opt.append(save_decoded_options[i].canonical_option[1]);
+ common_opt.append(" ");
+ }
+ if (!strcmp(save_decoded_options[i].canonical_option[0],"-std=gnu90")) {
+ common_opt.append(" -std=gnu90 ");
+ }
+ }
+
+ string extra_opt = "";
+ for (int i = 0; i< save_decoded_options_count; ++i) {
+ if (strcmp(save_decoded_options[i].canonical_option[0],"-I") &&
+ strcmp(save_decoded_options[i].canonical_option[0],"-D") &&
+ strcmp(save_decoded_options[i].canonical_option[0],"-o")) {
+ extra_opt.append(save_decoded_options[i].canonical_option[0]);
+ extra_opt.append(" ");
+ }
+ }
+
+ if (execl(serverPath.c_str(), port.c_str(), level.c_str(),
+ inputFile.c_str(), cwd.c_str(), common_opt.c_str(), extra_opt.c_str(), outputName.c_str(), NULL) == -1)
+ {
+ return true;
+ }
+ return false;
+
+}
+
int PluginClient::ServerStart(pid_t& pid)
{
if (!grpcPort.FindUnusedPort()) {
- LOGE("cannot find port for grpc,port 40001-65535 all used!\n");
- return -1;
+ // Rectify the fault that the port number is not released
+ // because the client is abnormal.
+ LOGW("cannot find port for grpc, try again!\n");
+ if (!grpcPort.FindUnusedPort()) {
+ LOGE("cannot find port for grpc,port 40001-65534 all used!\n");
+ return -1;
+ }
}
int ret = 0;
@@ -1575,7 +1644,8 @@ int PluginClient::ServerStart(pid_t& pid)
if (pid == 0) {
LOGI("start plugin server!\n");
string serverPath = input.GetServerPath();
- if (execl(serverPath.c_str(), port.c_str(), std::to_string(input.GetLogLevel()).c_str(), NULL) == -1) {
+ string level = std::to_string(input.GetLogLevel());
+ if (ExecuteWithCommand(serverPath, port, level)) {
DeleteGrpcPort();
LOGE("server start fail! please check serverPath:%s\n", serverPath.c_str());
ret = -1;
diff --git a/lib/Translate/GimpleToPluginOps.cpp b/lib/Translate/GimpleToPluginOps.cpp
index 80d4e87..4617c78 100644
--- a/lib/Translate/GimpleToPluginOps.cpp
+++ b/lib/Translate/GimpleToPluginOps.cpp
@@ -1505,9 +1505,14 @@ Value GimpleToPluginOps::TreeToValue(uint64_t treeId)
unsigned HOST_WIDE_INT uinit = tree_to_uhwi(t);
initAttr = builder.getI64IntegerAttr(uinit);
} else {
- abort();
+ wide_int val = wi::to_wide(t);
+ if (wi::neg_p(val, TYPE_SIGN(TREE_TYPE(t)))) {
+ val = -val;
+ }
+ signed HOST_WIDE_INT init = val.to_shwi();
+ initAttr = builder.getI64IntegerAttr(init);
}
- GetTreeAttr(treeId, readOnly, rPluginType);
+ GetTreeAttr(treeId, readOnly, rPluginType);
opValue = builder.create<ConstOp>(
builder.getUnknownLoc(), treeId, IDefineCode::IntCST,
readOnly, initAttr, rPluginType);
@@ -1887,4 +1892,4 @@ Value GimpleToPluginOps::MakeSsaName(mlir::Type type)
return TreeToValue(retId);
}
-} // namespace PluginIR
\ No newline at end of file
+} // namespace PluginIR
--
2.33.0

View File

@ -1,6 +1,6 @@
Name: pin-gcc-client
Version: 0.4.1
Release: 4
Release: 9
Summary: A Pin (Plug-IN framework) client is implemented based on GCC plugin and can execute the compiler optimization pass in GCC.
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD
URL: https://gitee.com/src-openeuler/pin-gcc-client
@ -16,19 +16,18 @@ Patch3: 0003-Pin-gcc-client-Init-a-SimpleIPAPASS.patch
Patch4: 0004-Pin-gcc-client-Add-CGnodeOp.patch
Patch5: 0005-Pin-gcc-client-Add-support-for-decl-and-field-SetDec.patch
Patch6: 0006-Pin-gcc-client-Add-GetDeclType.patch
Patch7: 0007-Pin-gcc-client-Fix-VectorType.patch
Patch8: 0008-Pin-gcc-client-Fix-struct-self-contained-CallOp-Tree.patch
Patch9: 0009-Pin-gcc-client-Fix-TreeToValue-VAR_DECL-and-ARRAY_TY.patch
Patch10: 0010-PluginClient-Fix-the-bug-during-multi-process-compil.patch
Patch11: 0011-Fix-BUILD-errors.patch
Patch12: 0012-PluginClient-Update-transfer-command.patch
%description
A Pin (Plug-IN framework) client is implemented based on GCC plugin and can execute the compiler optimization pass in GCC.
%prep
%setup -q
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%autosetup -p1
mkdir -p _build
cd _build
@ -65,6 +64,36 @@ find %{_libdir} -type f -name "*.so" -exec strip "{}" ";"
%config(noreplace) /etc/ld.so.conf.d/%{name}-%{_arch}.conf
%changelog
* Tue Sep 19 2023 dingguangya <dingguangya1@huawei.com> - 0.4.1-9
- Type:SPEC
- ID:NA
- SUG:NA
- DESC:Sync patch from openeuler/pin-gcc-client
* Tue May 09 2023 shenbowen <shenbowen@xfusion.com> - 0.4.1-8
- Type:SPEC
- ID:NA
- SUG:NA
- DESC:modify %patchxxx -p1 to %autosetup -p1
* Thu Apr 6 2023 dingguangya <dingguangya1@huawei.com> - 0.4.1-7
- Type:Update
- ID:NA
- SUG:NA
- DESC:Fix the bug during multi-process compilation
* Sat 25 2023 dingguangya <dingguangya1@huawei.com> - 0.4.1-6
- Type:Update
- ID:NA
- SUG:NA
- DESC:Fix TreeToValue-VAR_DECL and ARRAY_TYPE-getDomainIndex
* Fri Mar 17 2023 dingguangya <dingguangya1@huawei.com> - 0.4.1-5
- Type:Update
- ID:NA
- SUG:NA
- DESC:Fix VectorType CallOp TreeTOValue
* Tue Mar 7 2023 dingguangya <dingguangya1@huawei.com> - 0.4.1-4
- Type:Update
- ID:NA