[llvm] r207803 - [Stackmaps] Replace the custom ConstantPool class with a MapVector.
Juergen Ributzka
juergen at apple.com
Thu May 1 15:21:24 PDT 2014
Author: ributzka
Date: Thu May 1 17:21:24 2014
New Revision: 207803
URL: http://llvm.org/viewvc/llvm-project?rev=207803&view=rev
Log:
[Stackmaps] Replace the custom ConstantPool class with a MapVector.
Modified:
llvm/trunk/include/llvm/CodeGen/StackMaps.h
llvm/trunk/lib/CodeGen/StackMaps.cpp
Modified: llvm/trunk/include/llvm/CodeGen/StackMaps.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/StackMaps.h?rev=207803&r1=207802&r2=207803&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/StackMaps.h (original)
+++ llvm/trunk/include/llvm/CodeGen/StackMaps.h Thu May 1 17:21:24 2014
@@ -133,6 +133,7 @@ public:
private:
typedef SmallVector<Location, 8> LocationVec;
typedef SmallVector<LiveOutReg, 8> LiveOutVec;
+ typedef MapVector<int64_t, int64_t> ConstantPool;
typedef MapVector<const MCSymbol *, uint64_t> FnStackSizeMap;
struct CallsiteInfo {
@@ -149,26 +150,6 @@ private:
typedef std::vector<CallsiteInfo> CallsiteInfoList;
- struct ConstantPool {
- private:
- typedef std::map<int64_t, size_t> ConstantsMap;
- std::vector<int64_t> 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;
Modified: llvm/trunk/lib/CodeGen/StackMaps.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StackMaps.cpp?rev=207803&r1=207802&r2=207803&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/StackMaps.cpp (original)
+++ llvm/trunk/lib/CodeGen/StackMaps.cpp Thu May 1 17:21:24 2014
@@ -209,7 +209,8 @@ void StackMaps::recordStackMapOpers(cons
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::serializeToStackMapSecti
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::serializeToStackMapSecti
}
// 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::serializeToStackMapSecti
AP.OutStreamer.AddBlankLine();
CSInfos.clear();
+ ConstPool.clear();
}
More information about the llvm-commits
mailing list