From 23fc1727e755feb734e500214ca193b5d01007ff Mon Sep 17 00:00:00 2001 From: Juergen Ributzka Date: Thu, 1 May 2014 22:21:24 +0000 Subject: [PATCH] [Stackmaps] Replace the custom ConstantPool class with a MapVector. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207803 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/StackMaps.h | 21 +-------------------- lib/CodeGen/StackMaps.cpp | 12 +++++++----- 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/include/llvm/CodeGen/StackMaps.h b/include/llvm/CodeGen/StackMaps.h index f903a36a3a2..67b815f9dd2 100644 --- a/include/llvm/CodeGen/StackMaps.h +++ b/include/llvm/CodeGen/StackMaps.h @@ -133,6 +133,7 @@ public: private: typedef SmallVector LocationVec; typedef SmallVector LiveOutVec; + typedef MapVector ConstantPool; typedef MapVector FnStackSizeMap; struct CallsiteInfo { @@ -149,26 +150,6 @@ private: typedef std::vector CallsiteInfoList; - struct ConstantPool { - private: - typedef std::map ConstantsMap; - std::vector ConstantsList; - ConstantsMap ConstantIndexes; - - public: - size_t getNumConstants() const { return ConstantsList.size(); } - int64_t getConstant(size_t Idx) const { return ConstantsList[Idx]; } - size_t getConstantIndex(int64_t ConstVal) { - size_t NextIdx = ConstantsList.size(); - ConstantsMap::const_iterator I = - ConstantIndexes.insert(ConstantIndexes.end(), - std::make_pair(ConstVal, NextIdx)); - if (I->second == NextIdx) - ConstantsList.push_back(ConstVal); - return I->second; - } - }; - AsmPrinter &AP; CallsiteInfoList CSInfos; ConstantPool ConstPool; diff --git a/lib/CodeGen/StackMaps.cpp b/lib/CodeGen/StackMaps.cpp index 337982bc157..81a336eeda8 100644 --- a/lib/CodeGen/StackMaps.cpp +++ b/lib/CodeGen/StackMaps.cpp @@ -209,7 +209,8 @@ void StackMaps::recordStackMapOpers(const MachineInstr &MI, uint64_t ID, if (I->LocType == Location::Constant && ((I->Offset + (int64_t(1)<<31)) >> 32) != 0) { I->LocType = Location::ConstantIndex; - I->Offset = ConstPool.getConstantIndex(I->Offset); + auto Result = ConstPool.insert(std::make_pair(I->Offset, I->Offset)); + I->Offset = Result.first - ConstPool.begin(); } } @@ -334,9 +335,9 @@ void StackMaps::serializeToStackMapSection() { DEBUG(dbgs() << WSMP << "#functions = " << FnStackSize.size() << '\n'); AP.OutStreamer.EmitIntValue(FnStackSize.size(), 4); // Num constants. - DEBUG(dbgs() << WSMP << "#constants = " << ConstPool.getNumConstants() + DEBUG(dbgs() << WSMP << "#constants = " << ConstPool.size() << '\n'); - AP.OutStreamer.EmitIntValue(ConstPool.getNumConstants(), 4); + AP.OutStreamer.EmitIntValue(ConstPool.size(), 4); // Num callsites. DEBUG(dbgs() << WSMP << "#callsites = " << CSInfos.size() << '\n'); AP.OutStreamer.EmitIntValue(CSInfos.size(), 4); @@ -349,8 +350,8 @@ void StackMaps::serializeToStackMapSection() { } // Constant pool entries. - for (unsigned i = 0; i < ConstPool.getNumConstants(); ++i) - AP.OutStreamer.EmitIntValue(ConstPool.getConstant(i), 8); + for (auto Constant : ConstPool) + AP.OutStreamer.EmitIntValue(Constant.second, 8); // Callsite entries. for (CallsiteInfoList::const_iterator CSII = CSInfos.begin(), @@ -473,4 +474,5 @@ void StackMaps::serializeToStackMapSection() { AP.OutStreamer.AddBlankLine(); CSInfos.clear(); + ConstPool.clear(); } -- 2.34.1