diff --git a/IGC/Compiler/CISACodeGen/MemOpt.cpp b/IGC/Compiler/CISACodeGen/MemOpt.cpp index b135b937e2d1..a05d75307d7c 100644 --- a/IGC/Compiler/CISACodeGen/MemOpt.cpp +++ b/IGC/Compiler/CISACodeGen/MemOpt.cpp @@ -2561,8 +2561,6 @@ namespace { bool getAddressDiffIfConstant(Instruction* I0, Instruction* I1, int64_t& ConstBO); // Create unique identified struct type - SmallVector m_allLayoutStructTypes; - void initLayoutStructType(Module* M); StructType* getOrCreateUniqueIdentifiedStructType( ArrayRef EltTys, bool IsSOA, bool IsPacked = true); @@ -2576,7 +2574,6 @@ namespace { m_visited.clear(); m_instOrder.clear(); m_bundles.clear(); - m_allLayoutStructTypes.clear(); } }; } @@ -2799,8 +2796,6 @@ bool LdStCombine::runOnFunction(Function& F) } m_F = &F; - initLayoutStructType(m_F->getParent()); - // Initialize symbolic evaluation m_symEval.setDataLayout(m_DL); @@ -3423,23 +3418,6 @@ void LdStCombine::mergeConstElements( EltVals.insert(EltVals.end(), mergedElts.begin(), mergedElts.end()); } -// Get all layout struct types created already for different functions in -// the same module. -// -// This is for creating unique struct layout type per module. Layout -// struct type is identified, but if two identified layout structs are -// the same layout, they are the same. -void LdStCombine::initLayoutStructType(Module* M) -{ - auto modAllNamedStructTys = M->getIdentifiedStructTypes(); - for (auto II : modAllNamedStructTys) { - StructType* stTy = II; - if (isLayoutStructType(stTy)) { - m_allLayoutStructTypes.push_back(stTy); - } - } -} - // This is to make sure to reuse the layout types. Two identified structs have // the same layout if // 1. both are SOA or both are AOS; and @@ -3448,7 +3426,8 @@ void LdStCombine::initLayoutStructType(Module* M) StructType* LdStCombine::getOrCreateUniqueIdentifiedStructType( ArrayRef EltTys, bool IsSOA, bool IsPacked) { - for (auto II : m_allLayoutStructTypes) { + auto& layoutStructTypes = m_CGC->getLayoutStructTypes(); + for (auto II : layoutStructTypes) { StructType* stTy = II; if (IsPacked == stTy->isPacked() && IsSOA == isLayoutStructTypeSOA(stTy) && @@ -3460,7 +3439,7 @@ StructType* LdStCombine::getOrCreateUniqueIdentifiedStructType( StructType* StTy = StructType::create(EltTys, IsSOA ? getStructNameForSOALayout() : getStructNameForAOSLayout(), IsPacked); - m_allLayoutStructTypes.push_back(StTy); + layoutStructTypes.push_back(StTy); return StTy; } diff --git a/IGC/Compiler/CodeGenPublic.h b/IGC/Compiler/CodeGenPublic.h index bd9a3eaba367..0dd6acf962fe 100644 --- a/IGC/Compiler/CodeGenPublic.h +++ b/IGC/Compiler/CodeGenPublic.h @@ -849,6 +849,8 @@ namespace IGC SafeIntrinsicIDCacheTy m_SafeIntrinsicIDCache; /// metadata caching UserAddrSpaceMD m_UserAddrSpaceMD; + // structType caching : for unique identified struct type + llvm::SmallVector m_allLayoutStructTypes; void AddRef(); void Release(); }; @@ -1101,6 +1103,10 @@ namespace IGC IGC_ASSERT(llvmCtxWrapper); return llvmCtxWrapper->m_UserAddrSpaceMD; } + llvm::SmallVector& getLayoutStructTypes() { + IGC_ASSERT(llvmCtxWrapper); + return llvmCtxWrapper->m_allLayoutStructTypes; + } unsigned int GetSIMDInfoOffset(SIMDMode simd, ShaderDispatchMode mode) {