From 01acfbde462cc64f12678182ba344d624f6a3c4e Mon Sep 17 00:00:00 2001 From: Wen HU Date: Sun, 21 Aug 2022 12:06:13 -0700 Subject: [PATCH] utilize type attributes from pointer/array/struct --- src/mapleall/maple_ir/include/debug_info.h | 4 ++-- src/mapleall/maple_ir/src/debug_info.cpp | 16 ++++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/mapleall/maple_ir/include/debug_info.h b/src/mapleall/maple_ir/include/debug_info.h index 73686c3c89..909ec12f9f 100644 --- a/src/mapleall/maple_ir/include/debug_info.h +++ b/src/mapleall/maple_ir/include/debug_info.h @@ -829,8 +829,8 @@ class DebugInfo { DBGDie *GetOrCreatePrimTypeDie(MIRType *ty); DBGDie *GetOrCreateTypeDie(TyIdx tyidx); DBGDie *GetOrCreateTypeDie(MIRType *type); - DBGDie *GetOrCreateTypeDie(AttrKind attr, DBGDie *typeDie); - DBGDie *GetOrCreateTypeDie(TypeAttrs attrs, DBGDie *typeDie); + DBGDie *GetOrCreateTypeDieWithAttr(AttrKind attr, DBGDie *typeDie); + DBGDie *GetOrCreateTypeDieWithAttr(TypeAttrs attrs, DBGDie *typeDie); DBGDie *GetOrCreatePointTypeDie(const MIRPtrType *ptrType); DBGDie *GetOrCreateArrayTypeDie(const MIRArrayType *arrayType); DBGDie *GetOrCreateStructTypeDie(const MIRType *type); diff --git a/src/mapleall/maple_ir/src/debug_info.cpp b/src/mapleall/maple_ir/src/debug_info.cpp index a849dd5cd0..5e1d6a1214 100644 --- a/src/mapleall/maple_ir/src/debug_info.cpp +++ b/src/mapleall/maple_ir/src/debug_info.cpp @@ -351,7 +351,7 @@ DBGDie *DebugInfo::GetAliasVarTypeDie(const MIRAliasVars &aliasVar, TyIdx tyidx) } ASSERT(typeDie, "null alias type DIE"); - return GetOrCreateTypeDie(aliasVar.attrs, typeDie); + return GetOrCreateTypeDieWithAttr(aliasVar.attrs, typeDie); } void DebugInfo::AddAliasDies(MapleMap &aliasMap, bool isLocal) { @@ -734,7 +734,7 @@ DBGDie *DebugInfo::CreateVarDie(MIRSymbol *sym, GStrIdx strIdx) { MIRType *type = sym->GetType(); DBGDie *typeDie = GetOrCreateTypeDie(type); - DBGDie *newDie = GetOrCreateTypeDie(sym->GetAttrs(), typeDie); + DBGDie *newDie = GetOrCreateTypeDieWithAttr(sym->GetAttrs(), typeDie); die->AddAttr(DW_AT_type, DW_FORM_ref4, newDie->GetId()); return die; @@ -906,6 +906,7 @@ DBGDie *DebugInfo::CreatePointedFuncTypeDie(MIRFuncType *fType) { die->AddAttr(DW_AT_prototyped, DW_FORM_data4, static_cast(fType->GetParamTypeList().size() > 0)); MIRType *retType = GlobalTables::GetTypeTable().GetTypeFromTyIdx(fType->GetRetTyIdx()); DBGDie *retTypeDie = GetOrCreateTypeDie(retType); + retTypeDie = GetOrCreateTypeDieWithAttr(fType->GetRetAttrs(), retTypeDie); die->AddAttr(DW_AT_type, DW_FORM_ref4, retTypeDie->GetId()); compUnit->AddSubVec(die); @@ -922,7 +923,7 @@ DBGDie *DebugInfo::CreatePointedFuncTypeDie(MIRFuncType *fType) { return die; } -DBGDie *DebugInfo::GetOrCreateTypeDie(AttrKind attr, DBGDie *typeDie) { +DBGDie *DebugInfo::GetOrCreateTypeDieWithAttr(AttrKind attr, DBGDie *typeDie) { DBGDie *die = typeDie; uint32 dieId = typeDie->GetId(); uint32 newId = 0; @@ -957,12 +958,12 @@ DBGDie *DebugInfo::GetOrCreateTypeDie(AttrKind attr, DBGDie *typeDie) { return die; } -DBGDie *DebugInfo::GetOrCreateTypeDie(TypeAttrs attrs, DBGDie *typeDie) { +DBGDie *DebugInfo::GetOrCreateTypeDieWithAttr(TypeAttrs attrs, DBGDie *typeDie) { if (attrs.GetAttr(ATTR_const)) { - typeDie = GetOrCreateTypeDie(ATTR_const, typeDie); + typeDie = GetOrCreateTypeDieWithAttr(ATTR_const, typeDie); } if (attrs.GetAttr(ATTR_volatile)) { - typeDie = GetOrCreateTypeDie(ATTR_volatile, typeDie); + typeDie = GetOrCreateTypeDieWithAttr(ATTR_volatile, typeDie); } return typeDie; } @@ -1110,6 +1111,7 @@ DBGDie *DebugInfo::GetOrCreatePointTypeDie(const MIRPtrType *ptrType) { MIRType *type = ptrType->GetPointedType(); DBGDie *typeDie = GetOrCreateTypeDie(type); + typeDie = GetOrCreateTypeDieWithAttr(ptrType->GetTypeAttrs(), typeDie); // for <* void> and if ((type != nullptr) && (type->GetPrimType() == PTY_void || type->GetKind() == kTypeFunction)) { @@ -1171,6 +1173,7 @@ DBGDie *DebugInfo::GetOrCreateArrayTypeDie(const MIRArrayType *arrayType) { MIRType *type = arrayType->GetElemType(); DBGDie *typeDie = GetOrCreateTypeDie(type); + typeDie = GetOrCreateTypeDieWithAttr(arrayType->GetTypeAttrs(), typeDie); DBGDie *die = module->GetMemPool()->New(module, DW_TAG_array_type); die->AddAttr(DW_AT_byte_size, DW_FORM_data4, k8BitSize); @@ -1354,6 +1357,7 @@ DBGDie *DebugInfo::CreateStructTypeDie(GStrIdx strIdx, const MIRStructType *stru die = module->GetMemPool()->New(module, tag); tyIdxDieIdMap[structType->GetTypeIndex().GetIdx()] = die->GetId(); } + die = GetOrCreateTypeDieWithAttr(structType->GetTypeAttrs(), die); if (strIdx.GetIdx() != 0) { stridxDieIdMap[strIdx.GetIdx()] = die->GetId(); -- Gitee