<div dir="rtl"><div dir="ltr">Thanks!</div></div><div class="gmail_extra"><br><div class="gmail_quote"><div dir="ltr">2014-11-19 7:49 GMT+02:00 David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span>:</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: dblaikie<br>
Date: Tue Nov 18 23:49:42 2014<br>
New Revision: 222319<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=222319&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=222319&view=rev</a><br>
Log:<br>
Remove StringMap::GetOrCreateValue in favor of StringMap::insert<br>
<br>
Having two ways to do this doesn't seem terribly helpful and<br>
consistently using the insert version (which we already has) seems like<br>
it'll make the code easier to understand to anyone working with standard<br>
data structures. (I also updated many references to the Entry's<br>
key and value to use first() and second instead of getKey{Data,Length,}<br>
and get/setValue - for similar consistency)<br>
<br>
Also removes the GetOrCreateValue functions so there's less surface area<br>
to StringMap to fix/improve/change/accommodate move semantics, etc.<br>
<br>
Modified:<br>
llvm/trunk/include/llvm/ADT/StringMap.h<br>
llvm/trunk/include/llvm/LTO/LTOModule.h<br>
llvm/trunk/include/llvm/MC/StringTableBuilder.h<br>
llvm/trunk/include/llvm/TableGen/StringToOffsetTable.h<br>
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp<br>
llvm/trunk/lib/CodeGen/GCMetadata.cpp<br>
llvm/trunk/lib/IR/Constants.cpp<br>
llvm/trunk/lib/IR/LLVMContext.cpp<br>
llvm/trunk/lib/IR/Module.cpp<br>
llvm/trunk/lib/IR/Type.cpp<br>
llvm/trunk/lib/IR/ValueSymbolTable.cpp<br>
llvm/trunk/lib/LTO/LTOModule.cpp<br>
llvm/trunk/lib/Linker/LinkModules.cpp<br>
llvm/trunk/lib/MC/MCContext.cpp<br>
llvm/trunk/lib/MC/MCDwarf.cpp<br>
llvm/trunk/lib/Support/CommandLine.cpp<br>
llvm/trunk/lib/Support/Host.cpp<br>
llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp<br>
llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp<br>
llvm/trunk/tools/yaml2obj/yaml2elf.cpp<br>
llvm/trunk/unittests/ADT/StringMapTest.cpp<br>
llvm/trunk/utils/TableGen/CodeGenRegisters.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/ADT/StringMap.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringMap.h?rev=222319&r1=222318&r2=222319&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringMap.h?rev=222319&r1=222318&r2=222319&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/ADT/StringMap.h (original)<br>
+++ llvm/trunk/include/llvm/ADT/StringMap.h Tue Nov 18 23:49:42 2014<br>
@@ -296,7 +296,7 @@ public:<br>
}<br>
<br>
ValueTy &operator[](StringRef Key) {<br>
- return GetOrCreateValue(Key).getValue();<br>
+ return insert(std::make_pair(Key, ValueTy())).first->second;<br>
}<br>
<br>
/// count - Return 1 if the element is in the map, 0 otherwise.<br>
@@ -363,19 +363,6 @@ public:<br>
NumTombstones = 0;<br>
}<br>
<br>
- /// GetOrCreateValue - Look up the specified key in the table. If a value<br>
- /// exists, return it. Otherwise, default construct a value, insert it, and<br>
- /// return.<br>
- template <typename InitTy><br>
- MapEntryTy &GetOrCreateValue(StringRef Key, InitTy &&Val) {<br>
- return *insert(std::pair<StringRef, ValueTy>(<br>
- Key, std::forward<InitTy>(Val))).first;<br>
- }<br>
-<br>
- MapEntryTy &GetOrCreateValue(StringRef Key) {<br>
- return GetOrCreateValue(Key, ValueTy());<br>
- }<br>
-<br>
/// remove - Remove the specified key/value pair from the map, but do not<br>
/// erase it. This aborts if the key is not in the map.<br>
void remove(MapEntryTy *KeyValue) {<br>
<br>
Modified: llvm/trunk/include/llvm/LTO/LTOModule.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LTO/LTOModule.h?rev=222319&r1=222318&r2=222319&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LTO/LTOModule.h?rev=222319&r1=222318&r2=222319&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/LTO/LTOModule.h (original)<br>
+++ llvm/trunk/include/llvm/LTO/LTOModule.h Tue Nov 18 23:49:42 2014<br>
@@ -16,6 +16,7 @@<br>
<br>
#include "llvm-c/lto.h"<br>
#include "llvm/ADT/StringMap.h"<br>
+#include "llvm/ADT/StringSet.h"<br>
#include "llvm/IR/Module.h"<br>
#include "llvm/MC/MCContext.h"<br>
#include "llvm/MC/MCObjectFileInfo.h"<br>
@@ -37,8 +38,6 @@ namespace llvm {<br>
///<br>
struct LTOModule {<br>
private:<br>
- typedef StringMap<uint8_t> StringSet;<br>
-<br>
struct NameAndAttributes {<br>
const char *name;<br>
uint32_t attributes;<br>
@@ -50,13 +49,13 @@ private:<br>
<br>
std::unique_ptr<object::IRObjectFile> IRFile;<br>
std::unique_ptr<TargetMachine> _target;<br>
- StringSet _linkeropt_strings;<br>
+ StringSet<> _linkeropt_strings;<br>
std::vector<const char *> _deplibs;<br>
std::vector<const char *> _linkeropts;<br>
std::vector<NameAndAttributes> _symbols;<br>
<br>
// _defines and _undefines only needed to disambiguate tentative definitions<br>
- StringSet _defines;<br>
+ StringSet<> _defines;<br>
StringMap<NameAndAttributes> _undefines;<br>
std::vector<const char*> _asm_undefines;<br>
<br>
<br>
Modified: llvm/trunk/include/llvm/MC/StringTableBuilder.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/StringTableBuilder.h?rev=222319&r1=222318&r2=222319&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/StringTableBuilder.h?rev=222319&r1=222318&r2=222319&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/MC/StringTableBuilder.h (original)<br>
+++ llvm/trunk/include/llvm/MC/StringTableBuilder.h Tue Nov 18 23:49:42 2014<br>
@@ -26,7 +26,7 @@ public:<br>
/// copy of s. Can only be used before the table is finalized.<br>
StringRef add(StringRef s) {<br>
assert(!isFinalized());<br>
- return StringIndexMap.GetOrCreateValue(s, 0).getKey();<br>
+ return StringIndexMap.insert(std::make_pair(s, 0)).first->first();<br>
}<br>
<br>
enum Kind {<br>
<br>
Modified: llvm/trunk/include/llvm/TableGen/StringToOffsetTable.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/TableGen/StringToOffsetTable.h?rev=222319&r1=222318&r2=222319&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/TableGen/StringToOffsetTable.h?rev=222319&r1=222318&r2=222319&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/TableGen/StringToOffsetTable.h (original)<br>
+++ llvm/trunk/include/llvm/TableGen/StringToOffsetTable.h Tue Nov 18 23:49:42 2014<br>
@@ -28,16 +28,16 @@ class StringToOffsetTable {<br>
<br>
public:<br>
unsigned GetOrAddStringOffset(StringRef Str, bool appendZero = true) {<br>
- StringMapEntry<unsigned> &Entry = StringOffset.GetOrCreateValue(Str, -1U);<br>
- if (Entry.getValue() == -1U) {<br>
+ auto IterBool =<br>
+ StringOffset.insert(std::make_pair(Str, AggregateString.size()));<br>
+ if (IterBool.second) {<br>
// Add the string to the aggregate if this is the first time found.<br>
- Entry.setValue(AggregateString.size());<br>
AggregateString.append(Str.begin(), Str.end());<br>
if (appendZero)<br>
AggregateString += '\0';<br>
}<br>
<br>
- return Entry.getValue();<br>
+ return IterBool.first->second;<br>
}<br>
<br>
void EmitString(raw_ostream &O) {<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp?rev=222319&r1=222318&r2=222319&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp?rev=222319&r1=222318&r2=222319&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp Tue Nov 18 23:49:42 2014<br>
@@ -16,8 +16,7 @@ static std::pair<MCSymbol *, unsigned> &<br>
getEntry(AsmPrinter &Asm,<br>
StringMap<std::pair<MCSymbol *, unsigned>, BumpPtrAllocator &> &Pool,<br>
StringRef Prefix, StringRef Str) {<br>
- std::pair<MCSymbol *, unsigned> &Entry =<br>
- Pool.GetOrCreateValue(Str).getValue();<br>
+ std::pair<MCSymbol *, unsigned> &Entry = Pool[Str];<br>
if (!Entry.first) {<br>
Entry.second = Pool.size() - 1;<br>
Entry.first = Asm.GetTempSymbol(Prefix, Entry.second);<br>
<br>
Modified: llvm/trunk/lib/CodeGen/GCMetadata.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GCMetadata.cpp?rev=222319&r1=222318&r2=222319&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GCMetadata.cpp?rev=222319&r1=222318&r2=222319&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/GCMetadata.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/GCMetadata.cpp Tue Nov 18 23:49:42 2014<br>
@@ -73,7 +73,7 @@ GCStrategy *GCModuleInfo::getOrCreateStr<br>
std::unique_ptr<GCStrategy> S = I->instantiate();<br>
S->M = M;<br>
S->Name = Name;<br>
- StrategyMap.GetOrCreateValue(Name).setValue(S.get());<br>
+ StrategyMap[Name] = S.get();<br>
StrategyList.push_back(std::move(S));<br>
return StrategyList.back().get();<br>
}<br>
<br>
Modified: llvm/trunk/lib/IR/Constants.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Constants.cpp?rev=222319&r1=222318&r2=222319&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Constants.cpp?rev=222319&r1=222318&r2=222319&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/IR/Constants.cpp (original)<br>
+++ llvm/trunk/lib/IR/Constants.cpp Tue Nov 18 23:49:42 2014<br>
@@ -2436,14 +2436,16 @@ Constant *ConstantDataSequential::getImp<br>
return ConstantAggregateZero::get(Ty);<br>
<br>
// Do a lookup to see if we have already formed one of these.<br>
- StringMap<ConstantDataSequential*>::MapEntryTy &Slot =<br>
- Ty->getContext().pImpl->CDSConstants.GetOrCreateValue(Elements);<br>
+ auto &Slot =<br>
+ *Ty->getContext()<br>
+ .pImpl->CDSConstants.insert(std::make_pair(Elements, nullptr))<br>
+ .first;<br>
<br>
// The bucket can point to a linked list of different CDS's that have the same<br>
// body but different types. For example, 0,0,0,1 could be a 4 element array<br>
// of i8, or a 1-element array of i32. They'll both end up in the same<br>
/// StringMap bucket, linked up by their Next pointers. Walk the list.<br>
- ConstantDataSequential **Entry = &Slot.getValue();<br>
+ ConstantDataSequential **Entry = &Slot.second;<br>
for (ConstantDataSequential *Node = *Entry; Node;<br>
Entry = &Node->Next, Node = *Entry)<br>
if (Node->getType() == Ty)<br>
@@ -2452,10 +2454,10 @@ Constant *ConstantDataSequential::getImp<br>
// Okay, we didn't get a hit. Create a node of the right class, link it in,<br>
// and return it.<br>
if (isa<ArrayType>(Ty))<br>
- return *Entry = new ConstantDataArray(Ty, Slot.getKeyData());<br>
+ return *Entry = new ConstantDataArray(Ty, Slot.first().data());<br>
<br>
assert(isa<VectorType>(Ty));<br>
- return *Entry = new ConstantDataVector(Ty, Slot.getKeyData());<br>
+ return *Entry = new ConstantDataVector(Ty, Slot.first().data());<br>
}<br>
<br>
void ConstantDataSequential::destroyConstant() {<br>
<br>
Modified: llvm/trunk/lib/IR/LLVMContext.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/LLVMContext.cpp?rev=222319&r1=222318&r2=222319&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/LLVMContext.cpp?rev=222319&r1=222318&r2=222319&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/IR/LLVMContext.cpp (original)<br>
+++ llvm/trunk/lib/IR/LLVMContext.cpp Tue Nov 18 23:49:42 2014<br>
@@ -253,9 +253,10 @@ unsigned LLVMContext::getMDKindID(String<br>
assert(isValidName(Name) && "Invalid MDNode name");<br>
<br>
// If this is new, assign it its ID.<br>
- return<br>
- pImpl->CustomMDKindNames.GetOrCreateValue(<br>
- Name, pImpl->CustomMDKindNames.size()).second;<br>
+ return pImpl->CustomMDKindNames.insert(std::make_pair(<br>
+ Name,<br>
+ pImpl->CustomMDKindNames.size()))<br>
+ .first->second;<br>
}<br>
<br>
/// getHandlerNames - Populate client supplied smallvector using custome<br>
<br>
Modified: llvm/trunk/lib/IR/Module.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Module.cpp?rev=222319&r1=222318&r2=222319&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Module.cpp?rev=222319&r1=222318&r2=222319&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/IR/Module.cpp (original)<br>
+++ llvm/trunk/lib/IR/Module.cpp Tue Nov 18 23:49:42 2014<br>
@@ -452,9 +452,7 @@ unsigned Module::getDwarfVersion() const<br>
}<br>
<br>
Comdat *Module::getOrInsertComdat(StringRef Name) {<br>
- Comdat C;<br>
- StringMapEntry<Comdat> &Entry =<br>
- ComdatSymTab.GetOrCreateValue(Name, std::move(C));<br>
+ auto &Entry = *ComdatSymTab.insert(std::make_pair(Name, Comdat())).first;<br>
<a href="http://Entry.second.Name" target="_blank">Entry.second.Name</a> = &Entry;<br>
return &Entry.second;<br>
}<br>
<br>
Modified: llvm/trunk/lib/IR/Type.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Type.cpp?rev=222319&r1=222318&r2=222319&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Type.cpp?rev=222319&r1=222318&r2=222319&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/IR/Type.cpp (original)<br>
+++ llvm/trunk/lib/IR/Type.cpp Tue Nov 18 23:49:42 2014<br>
@@ -458,10 +458,11 @@ void StructType::setName(StringRef Name)<br>
}<br>
<br>
// Look up the entry for the name.<br>
- EntryTy *Entry = &getContext().pImpl->NamedStructTypes.GetOrCreateValue(Name);<br>
-<br>
+ auto IterBool =<br>
+ getContext().pImpl->NamedStructTypes.insert(std::make_pair(Name, this));<br>
+<br>
// While we have a name collision, try a random rename.<br>
- if (Entry->getValue()) {<br>
+ if (!IterBool.second) {<br>
SmallString<64> TempStr(Name);<br>
TempStr.push_back('.');<br>
raw_svector_ostream TmpStream(TempStr);<br>
@@ -471,19 +472,16 @@ void StructType::setName(StringRef Name)<br>
TempStr.resize(NameSize + 1);<br>
TmpStream.resync();<br>
TmpStream << getContext().pImpl->NamedStructTypesUniqueID++;<br>
-<br>
- Entry = &getContext().pImpl-><br>
- NamedStructTypes.GetOrCreateValue(TmpStream.str());<br>
- } while (Entry->getValue());<br>
- }<br>
<br>
- // Okay, we found an entry that isn't used. It's us!<br>
- Entry->setValue(this);<br>
+ IterBool = getContext().pImpl->NamedStructTypes.insert(<br>
+ std::make_pair(TmpStream.str(), this));<br>
+ } while (!IterBool.second);<br>
+ }<br>
<br>
// Delete the old string data.<br>
if (SymbolTableEntry)<br>
((EntryTy *)SymbolTableEntry)->Destroy(SymbolTable.getAllocator());<br>
- SymbolTableEntry = Entry;<br>
+ SymbolTableEntry = &*IterBool.first;<br>
}<br>
<br>
//===----------------------------------------------------------------------===//<br>
<br>
Modified: llvm/trunk/lib/IR/ValueSymbolTable.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/ValueSymbolTable.cpp?rev=222319&r1=222318&r2=222319&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/ValueSymbolTable.cpp?rev=222319&r1=222318&r2=222319&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/IR/ValueSymbolTable.cpp (original)<br>
+++ llvm/trunk/lib/IR/ValueSymbolTable.cpp Tue Nov 18 23:49:42 2014<br>
@@ -56,11 +56,10 @@ void ValueSymbolTable::reinsertValue(Val<br>
raw_svector_ostream(UniqueName) << ++LastUnique;<br>
<br>
// Try insert the vmap entry with this suffix.<br>
- ValueName &NewName = vmap.GetOrCreateValue(UniqueName);<br>
- if (!NewName.getValue()) {<br>
+ auto IterBool = vmap.insert(std::make_pair(UniqueName, V));<br>
+ if (IterBool.second) {<br>
// Newly inserted name. Success!<br>
- NewName.setValue(V);<br>
- V->Name = &NewName;<br>
+ V->Name = &*IterBool.first;<br>
//DEBUG(dbgs() << " Inserted value: " << UniqueName << ": " << *V << "\n");<br>
return;<br>
}<br>
@@ -78,12 +77,11 @@ void ValueSymbolTable::removeValueName(V<br>
/// auto-renames the name and returns that instead.<br>
ValueName *ValueSymbolTable::createValueName(StringRef Name, Value *V) {<br>
// In the common case, the name is not already in the symbol table.<br>
- ValueName &Entry = vmap.GetOrCreateValue(Name);<br>
- if (!Entry.getValue()) {<br>
- Entry.setValue(V);<br>
+ auto IterBool = vmap.insert(std::make_pair(Name, V));<br>
+ if (IterBool.second) {<br>
//DEBUG(dbgs() << " Inserted value: " << Entry.getKeyData() << ": "<br>
// << *V << "\n");<br>
- return &Entry;<br>
+ return &*IterBool.first;<br>
}<br>
<br>
// Otherwise, there is a naming conflict. Rename this value.<br>
@@ -95,12 +93,11 @@ ValueName *ValueSymbolTable::createValue<br>
raw_svector_ostream(UniqueName) << ++LastUnique;<br>
<br>
// Try insert the vmap entry with this suffix.<br>
- ValueName &NewName = vmap.GetOrCreateValue(UniqueName);<br>
- if (!NewName.getValue()) {<br>
- // Newly inserted name. Success!<br>
- NewName.setValue(V);<br>
- //DEBUG(dbgs() << " Inserted value: " << UniqueName << ": " << *V << "\n");<br>
- return &NewName;<br>
+ auto IterBool = vmap.insert(std::make_pair(UniqueName, V));<br>
+ if (IterBool.second) {<br>
+ // DEBUG(dbgs() << " Inserted value: " << UniqueName << ": " << *V <<<br>
+ // "\n");<br>
+ return &*IterBool.first;<br>
}<br>
}<br>
}<br>
<br>
Modified: llvm/trunk/lib/LTO/LTOModule.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTOModule.cpp?rev=222319&r1=222318&r2=222319&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTOModule.cpp?rev=222319&r1=222318&r2=222319&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/LTO/LTOModule.cpp (original)<br>
+++ llvm/trunk/lib/LTO/LTOModule.cpp Tue Nov 18 23:49:42 2014<br>
@@ -249,27 +249,24 @@ void LTOModule::addObjCClass(const Globa<br>
// second slot in __OBJC,__class is pointer to superclass name<br>
std::string superclassName;<br>
if (objcClassNameFromExpression(c->getOperand(1), superclassName)) {<br>
- NameAndAttributes info;<br>
- StringMap<NameAndAttributes>::value_type &entry =<br>
- _undefines.GetOrCreateValue(superclassName);<br>
- if (!entry.getValue().name) {<br>
- const char *symbolName = entry.getKey().data();<br>
- <a href="http://info.name" target="_blank">info.name</a> = symbolName;<br>
+ auto IterBool =<br>
+ _undefines.insert(std::make_pair(superclassName, NameAndAttributes()));<br>
+ if (IterBool.second) {<br>
+ NameAndAttributes &info = IterBool.first->second;<br>
+ <a href="http://info.name" target="_blank">info.name</a> = IterBool.first->first().data();<br>
info.attributes = LTO_SYMBOL_DEFINITION_UNDEFINED;<br>
info.isFunction = false;<br>
info.symbol = clgv;<br>
- entry.setValue(info);<br>
}<br>
}<br>
<br>
// third slot in __OBJC,__class is pointer to class name<br>
std::string className;<br>
if (objcClassNameFromExpression(c->getOperand(2), className)) {<br>
- StringSet::value_type &entry = _defines.GetOrCreateValue(className);<br>
- entry.setValue(1);<br>
+ auto Iter = _defines.insert(className).first;<br>
<br>
NameAndAttributes info;<br>
- <a href="http://info.name" target="_blank">info.name</a> = entry.getKey().data();<br>
+ <a href="http://info.name" target="_blank">info.name</a> = Iter->first().data();<br>
info.attributes = LTO_SYMBOL_PERMISSIONS_DATA |<br>
LTO_SYMBOL_DEFINITION_REGULAR | LTO_SYMBOL_SCOPE_DEFAULT;<br>
info.isFunction = false;<br>
@@ -288,19 +285,17 @@ void LTOModule::addObjCCategory(const Gl<br>
if (!objcClassNameFromExpression(c->getOperand(1), targetclassName))<br>
return;<br>
<br>
- NameAndAttributes info;<br>
- StringMap<NameAndAttributes>::value_type &entry =<br>
- _undefines.GetOrCreateValue(targetclassName);<br>
+ auto IterBool =<br>
+ _undefines.insert(std::make_pair(targetclassName, NameAndAttributes()));<br>
<br>
- if (entry.getValue().name)<br>
+ if (!IterBool.second)<br>
return;<br>
<br>
- const char *symbolName = entry.getKey().data();<br>
- <a href="http://info.name" target="_blank">info.name</a> = symbolName;<br>
+ NameAndAttributes &info = IterBool.first->second;<br>
+ <a href="http://info.name" target="_blank">info.name</a> = IterBool.first->first().data();<br>
info.attributes = LTO_SYMBOL_DEFINITION_UNDEFINED;<br>
info.isFunction = false;<br>
info.symbol = clgv;<br>
- entry.setValue(info);<br>
}<br>
<br>
/// addObjCClassRef - Parse i386/ppc ObjC class list data structure.<br>
@@ -309,18 +304,17 @@ void LTOModule::addObjCClassRef(const Gl<br>
if (!objcClassNameFromExpression(clgv->getInitializer(), targetclassName))<br>
return;<br>
<br>
- NameAndAttributes info;<br>
- StringMap<NameAndAttributes>::value_type &entry =<br>
- _undefines.GetOrCreateValue(targetclassName);<br>
- if (entry.getValue().name)<br>
+ auto IterBool =<br>
+ _undefines.insert(std::make_pair(targetclassName, NameAndAttributes()));<br>
+<br>
+ if (!IterBool.second)<br>
return;<br>
<br>
- const char *symbolName = entry.getKey().data();<br>
- <a href="http://info.name" target="_blank">info.name</a> = symbolName;<br>
+ NameAndAttributes &info = IterBool.first->second;<br>
+ <a href="http://info.name" target="_blank">info.name</a> = IterBool.first->first().data();<br>
info.attributes = LTO_SYMBOL_DEFINITION_UNDEFINED;<br>
info.isFunction = false;<br>
info.symbol = clgv;<br>
- entry.setValue(info);<br>
}<br>
<br>
void LTOModule::addDefinedDataSymbol(const object::BasicSymbolRef &Sym) {<br>
@@ -439,12 +433,11 @@ void LTOModule::addDefinedSymbol(const c<br>
else<br>
attr |= LTO_SYMBOL_SCOPE_DEFAULT;<br>
<br>
- StringSet::value_type &entry = _defines.GetOrCreateValue(Name);<br>
- entry.setValue(1);<br>
+ auto Iter = _defines.insert(Name).first;<br>
<br>
// fill information structure<br>
NameAndAttributes info;<br>
- StringRef NameRef = entry.getKey();<br>
+ StringRef NameRef = Iter->first();<br>
<a href="http://info.name" target="_blank">info.name</a> = NameRef.data();<br>
assert(<a href="http://info.name" target="_blank">info.name</a>[NameRef.size()] == '\0');<br>
info.attributes = attr;<br>
@@ -459,15 +452,13 @@ void LTOModule::addDefinedSymbol(const c<br>
/// defined list.<br>
void LTOModule::addAsmGlobalSymbol(const char *name,<br>
lto_symbol_attributes scope) {<br>
- StringSet::value_type &entry = _defines.GetOrCreateValue(name);<br>
+ auto IterBool = _defines.insert(name);<br>
<br>
// only add new define if not already defined<br>
- if (entry.getValue())<br>
+ if (!IterBool.second)<br>
return;<br>
<br>
- entry.setValue(1);<br>
-<br>
- NameAndAttributes &info = _undefines[entry.getKey().data()];<br>
+ NameAndAttributes &info = _undefines[IterBool.first->first().data()];<br>
<br>
if (info.symbol == nullptr) {<br>
// FIXME: This is trying to take care of module ASM like this:<br>
@@ -479,7 +470,7 @@ void LTOModule::addAsmGlobalSymbol(const<br>
// much.<br>
<br>
// fill information structure<br>
- <a href="http://info.name" target="_blank">info.name</a> = entry.getKey().data();<br>
+ <a href="http://info.name" target="_blank">info.name</a> = IterBool.first->first().data();<br>
info.attributes =<br>
LTO_SYMBOL_PERMISSIONS_DATA | LTO_SYMBOL_DEFINITION_REGULAR | scope;<br>
info.isFunction = false;<br>
@@ -502,24 +493,21 @@ void LTOModule::addAsmGlobalSymbol(const<br>
/// addAsmGlobalSymbolUndef - Add a global symbol from module-level ASM to the<br>
/// undefined list.<br>
void LTOModule::addAsmGlobalSymbolUndef(const char *name) {<br>
- StringMap<NameAndAttributes>::value_type &entry =<br>
- _undefines.GetOrCreateValue(name);<br>
+ auto IterBool = _undefines.insert(std::make_pair(name, NameAndAttributes()));<br>
<br>
- _asm_undefines.push_back(entry.getKey().data());<br>
+ _asm_undefines.push_back(IterBool.first->first().data());<br>
<br>
// we already have the symbol<br>
- if (entry.getValue().name)<br>
+ if (!IterBool.second)<br>
return;<br>
<br>
uint32_t attr = LTO_SYMBOL_DEFINITION_UNDEFINED;<br>
attr |= LTO_SYMBOL_SCOPE_DEFAULT;<br>
- NameAndAttributes info;<br>
- <a href="http://info.name" target="_blank">info.name</a> = entry.getKey().data();<br>
+ NameAndAttributes &info = IterBool.first->second;<br>
+ <a href="http://info.name" target="_blank">info.name</a> = IterBool.first->first().data();<br>
info.attributes = attr;<br>
info.isFunction = false;<br>
info.symbol = nullptr;<br>
-<br>
- entry.setValue(info);<br>
}<br>
<br>
/// Add a symbol which isn't defined just yet to a list to be resolved later.<br>
@@ -531,16 +519,15 @@ void LTOModule::addPotentialUndefinedSym<br>
Sym.printName(OS);<br>
}<br>
<br>
- StringMap<NameAndAttributes>::value_type &entry =<br>
- _undefines.GetOrCreateValue(name);<br>
+ auto IterBool = _undefines.insert(std::make_pair(name, NameAndAttributes()));<br>
<br>
// we already have the symbol<br>
- if (entry.getValue().name)<br>
+ if (!IterBool.second)<br>
return;<br>
<br>
- NameAndAttributes info;<br>
+ NameAndAttributes &info = IterBool.first->second;<br>
<br>
- <a href="http://info.name" target="_blank">info.name</a> = entry.getKey().data();<br>
+ <a href="http://info.name" target="_blank">info.name</a> = IterBool.first->first().data();<br>
<br>
const GlobalValue *decl = IRFile->getSymbolGV(Sym.getRawDataRefImpl());<br>
<br>
@@ -551,8 +538,6 @@ void LTOModule::addPotentialUndefinedSym<br>
<br>
info.isFunction = isFunc;<br>
info.symbol = decl;<br>
-<br>
- entry.setValue(info);<br>
}<br>
<br>
/// parseSymbols - Parse the symbols from the module and model-level ASM and add<br>
@@ -625,8 +610,11 @@ void LTOModule::parseMetadata() {<br>
MDNode *MDOptions = cast<MDNode>(LinkerOptions->getOperand(i));<br>
for (unsigned ii = 0, ie = MDOptions->getNumOperands(); ii != ie; ++ii) {<br>
MDString *MDOption = cast<MDString>(MDOptions->getOperand(ii));<br>
- StringRef Op = _linkeropt_strings.<br>
- GetOrCreateValue(MDOption->getString()).getKey();<br>
+ // FIXME: Make StringSet::insert match Self-Associative Container<br>
+ // requirements, returning <iter,bool> rather than bool, and use that<br>
+ // here.<br>
+ StringRef Op =<br>
+ _linkeropt_strings.insert(MDOption->getString()).first->first();<br>
StringRef DepLibName = _target->getSubtargetImpl()<br>
->getTargetLowering()<br>
->getObjFileLowering()<br>
<br>
Modified: llvm/trunk/lib/Linker/LinkModules.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=222319&r1=222318&r2=222319&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=222319&r1=222318&r2=222319&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Linker/LinkModules.cpp (original)<br>
+++ llvm/trunk/lib/Linker/LinkModules.cpp Tue Nov 18 23:49:42 2014<br>
@@ -1463,7 +1463,7 @@ bool ModuleLinker::run() {<br>
computeTypeMapping();<br>
<br>
ComdatsChosen.clear();<br>
- for (const StringMapEntry<llvm::Comdat> &SMEC : SrcM->getComdatSymbolTable()) {<br>
+ for (const auto &SMEC : SrcM->getComdatSymbolTable()) {<br>
const Comdat &C = SMEC.getValue();<br>
if (ComdatsChosen.count(&C))<br>
continue;<br>
<br>
Modified: llvm/trunk/lib/MC/MCContext.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCContext.cpp?rev=222319&r1=222318&r2=222319&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCContext.cpp?rev=222319&r1=222318&r2=222319&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/MC/MCContext.cpp (original)<br>
+++ llvm/trunk/lib/MC/MCContext.cpp Tue Nov 18 23:49:42 2014<br>
@@ -100,16 +100,11 @@ void MCContext::reset() {<br>
MCSymbol *MCContext::GetOrCreateSymbol(StringRef Name) {<br>
assert(!Name.empty() && "Normal symbols cannot be unnamed!");<br>
<br>
- // Do the lookup and get the entire StringMapEntry. We want access to the<br>
- // key if we are creating the entry.<br>
- StringMapEntry<MCSymbol*> &Entry = Symbols.GetOrCreateValue(Name);<br>
- MCSymbol *Sym = Entry.getValue();<br>
+ MCSymbol *&Sym = Symbols[Name];<br>
<br>
- if (Sym)<br>
- return Sym;<br>
+ if (!Sym)<br>
+ Sym = CreateSymbol(Name);<br>
<br>
- Sym = CreateSymbol(Name);<br>
- Entry.setValue(Sym);<br>
return Sym;<br>
}<br>
<br>
@@ -120,19 +115,17 @@ MCSymbol *MCContext::getOrCreateSectionS<br>
<br>
StringRef Name = Section.getSectionName();<br>
<br>
- StringMapEntry<MCSymbol*> &Entry = Symbols.GetOrCreateValue(Name);<br>
- MCSymbol *OldSym = Entry.getValue();<br>
+ MCSymbol *&OldSym = Symbols[Name];<br>
if (OldSym && OldSym->isUndefined()) {<br>
Sym = OldSym;<br>
return OldSym;<br>
}<br>
<br>
- StringMapEntry<bool> *NameEntry = &UsedNames.GetOrCreateValue(Name);<br>
- NameEntry->setValue(true);<br>
- Sym = new (*this) MCSymbol(NameEntry->getKey(), /*isTemporary*/ false);<br>
+ auto NameIter = UsedNames.insert(std::make_pair(Name, true)).first;<br>
+ Sym = new (*this) MCSymbol(NameIter->getKey(), /*isTemporary*/ false);<br>
<br>
- if (!Entry.getValue())<br>
- Entry.setValue(Sym);<br>
+ if (!OldSym)<br>
+ OldSym = Sym;<br>
<br>
return Sym;<br>
}<br>
@@ -143,21 +136,21 @@ MCSymbol *MCContext::CreateSymbol(String<br>
if (AllowTemporaryLabels)<br>
isTemporary = Name.startswith(MAI->getPrivateGlobalPrefix());<br>
<br>
- StringMapEntry<bool> *NameEntry = &UsedNames.GetOrCreateValue(Name);<br>
- if (NameEntry->getValue()) {<br>
+ auto NameEntry = UsedNames.insert(std::make_pair(Name, true));<br>
+ if (!NameEntry.second) {<br>
assert(isTemporary && "Cannot rename non-temporary symbols");<br>
SmallString<128> NewName = Name;<br>
do {<br>
NewName.resize(Name.size());<br>
raw_svector_ostream(NewName) << NextUniqueID++;<br>
- NameEntry = &UsedNames.GetOrCreateValue(NewName);<br>
- } while (NameEntry->getValue());<br>
+ NameEntry = UsedNames.insert(std::make_pair(NewName, true));<br>
+ } while (!NameEntry.second);<br>
}<br>
- NameEntry->setValue(true);<br>
<br>
// Ok, the entry doesn't already exist. Have the MCSymbol object itself refer<br>
// to the copy of the string that is embedded in the UsedNames entry.<br>
- MCSymbol *Result = new (*this) MCSymbol(NameEntry->getKey(), isTemporary);<br>
+ MCSymbol *Result =<br>
+ new (*this) MCSymbol(NameEntry.first->getKey(), isTemporary);<br>
<br>
return Result;<br>
}<br>
<br>
Modified: llvm/trunk/lib/MC/MCDwarf.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=222319&r1=222318&r2=222319&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=222319&r1=222318&r2=222319&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/MC/MCDwarf.cpp (original)<br>
+++ llvm/trunk/lib/MC/MCDwarf.cpp Tue Nov 18 23:49:42 2014<br>
@@ -368,10 +368,10 @@ unsigned MCDwarfLineTableHeader::getFile<br>
FileNumber = SourceIdMap.size() + 1;<br>
assert((MCDwarfFiles.empty() || FileNumber == MCDwarfFiles.size()) &&<br>
"Don't mix autonumbered and explicit numbered line table usage");<br>
- StringMapEntry<unsigned> &Ent = SourceIdMap.GetOrCreateValue(<br>
- (Directory + Twine('\0') + FileName).str(), FileNumber);<br>
- if (Ent.getValue() != FileNumber)<br>
- return Ent.getValue();<br>
+ auto IterBool = SourceIdMap.insert(<br>
+ std::make_pair((Directory + Twine('\0') + FileName).str(), FileNumber));<br>
+ if (!IterBool.second)<br>
+ return IterBool.first->second;<br>
}<br>
// Make space for this FileNumber in the MCDwarfFiles vector if needed.<br>
MCDwarfFiles.resize(FileNumber + 1);<br>
<br>
Modified: llvm/trunk/lib/Support/CommandLine.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CommandLine.cpp?rev=222319&r1=222318&r2=222319&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CommandLine.cpp?rev=222319&r1=222318&r2=222319&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Support/CommandLine.cpp (original)<br>
+++ llvm/trunk/lib/Support/CommandLine.cpp Tue Nov 18 23:49:42 2014<br>
@@ -165,7 +165,7 @@ static void GetOptionInfo(SmallVectorImp<br>
// Handle named options.<br>
for (size_t i = 0, e = OptionNames.size(); i != e; ++i) {<br>
// Add argument to the argument map!<br>
- if (OptionsMap.GetOrCreateValue(OptionNames[i], O).second != O) {<br>
+ if (!OptionsMap.insert(std::make_pair(OptionNames[i], O)).second) {<br>
errs() << ProgramName << ": CommandLine Error: Option '"<br>
<< OptionNames[i] << "' registered more than once!\n";<br>
HadErrors = true;<br>
<br>
Modified: llvm/trunk/lib/Support/Host.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Host.cpp?rev=222319&r1=222318&r2=222319&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Host.cpp?rev=222319&r1=222318&r2=222319&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Support/Host.cpp (original)<br>
+++ llvm/trunk/lib/Support/Host.cpp Tue Nov 18 23:49:42 2014<br>
@@ -759,13 +759,13 @@ bool sys::getHostCPUFeatures(StringMap<b<br>
#endif<br>
<br>
if (LLVMFeatureStr != "")<br>
- Features.GetOrCreateValue(LLVMFeatureStr).setValue(true);<br>
+ Features[LLVMFeatureStr] = true;<br>
}<br>
<br>
#if defined(__aarch64__)<br>
// If we have all crypto bits we can add the feature<br>
if (crypto == (CAP_AES | CAP_PMULL | CAP_SHA1 | CAP_SHA2))<br>
- Features.GetOrCreateValue("crypto").setValue(true);<br>
+ Features["crypto"] = true;<br>
#endif<br>
<br>
return true;<br>
<br>
Modified: llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp?rev=222319&r1=222318&r2=222319&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp?rev=222319&r1=222318&r2=222319&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp (original)<br>
+++ llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp Tue Nov 18 23:49:42 2014<br>
@@ -4140,7 +4140,7 @@ bool AArch64AsmParser::parseDirectiveReq<br>
Parser.Lex(); // Consume the EndOfStatement<br>
<br>
auto pair = std::make_pair(IsVector, RegNum);<br>
- if (RegisterReqs.GetOrCreateValue(Name, pair).getValue() != pair)<br>
+ if (!RegisterReqs.insert(std::make_pair(Name, pair)).second)<br>
Warning(L, "ignoring redefinition of register alias '" + Name + "'");<br>
<br>
return true;<br>
<br>
Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=222319&r1=222318&r2=222319&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=222319&r1=222318&r2=222319&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original)<br>
+++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Tue Nov 18 23:49:42 2014<br>
@@ -8732,7 +8732,7 @@ bool ARMAsmParser::parseDirectiveReq(Str<br>
<br>
Parser.Lex(); // Consume the EndOfStatement<br>
<br>
- if (RegisterReqs.GetOrCreateValue(Name, Reg).getValue() != Reg) {<br>
+ if (!RegisterReqs.insert(std::make_pair(Name, Reg)).second) {<br>
Error(SRegLoc, "redefinition of '" + Name + "' does not match original.");<br>
return false;<br>
}<br>
<br>
Modified: llvm/trunk/tools/yaml2obj/yaml2elf.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/yaml2obj/yaml2elf.cpp?rev=222319&r1=222318&r2=222319&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/yaml2obj/yaml2elf.cpp?rev=222319&r1=222318&r2=222319&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/yaml2obj/yaml2elf.cpp (original)<br>
+++ llvm/trunk/tools/yaml2obj/yaml2elf.cpp Tue Nov 18 23:49:42 2014<br>
@@ -62,11 +62,7 @@ class NameToIdxMap {<br>
public:<br>
/// \returns true if name is already present in the map.<br>
bool addName(StringRef Name, unsigned i) {<br>
- StringMapEntry<int> &Entry = Map.GetOrCreateValue(Name, -1);<br>
- if (Entry.getValue() != -1)<br>
- return true;<br>
- Entry.setValue((int)i);<br>
- return false;<br>
+ return !Map.insert(std::make_pair(Name, (int)i)).second;<br>
}<br>
/// \returns true if name is not present in the map<br>
bool lookup(StringRef Name, unsigned &Idx) const {<br>
<br>
Modified: llvm/trunk/unittests/ADT/StringMapTest.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/StringMapTest.cpp?rev=222319&r1=222318&r2=222319&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/StringMapTest.cpp?rev=222319&r1=222318&r2=222319&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/unittests/ADT/StringMapTest.cpp (original)<br>
+++ llvm/trunk/unittests/ADT/StringMapTest.cpp Tue Nov 18 23:49:42 2014<br>
@@ -250,7 +250,7 @@ struct StringMapTestStruct {<br>
<br>
TEST_F(StringMapTest, NonDefaultConstructable) {<br>
StringMap<StringMapTestStruct> t;<br>
- t.GetOrCreateValue("Test", StringMapTestStruct(123));<br>
+ t.insert(std::make_pair("Test", StringMapTestStruct(123)));<br>
StringMap<StringMapTestStruct>::iterator iter = t.find("Test");<br>
ASSERT_NE(iter, t.end());<br>
ASSERT_EQ(iter->second.i, 123);<br>
@@ -278,15 +278,13 @@ private:<br>
<br>
TEST_F(StringMapTest, MoveOnly) {<br>
StringMap<MoveOnly> t;<br>
- t.GetOrCreateValue("Test", MoveOnly(42));<br>
+ t.insert(std::make_pair("Test", MoveOnly(42)));<br>
StringRef Key = "Test";<br>
StringMapEntry<MoveOnly>::Create(Key, MoveOnly(42))<br>
->Destroy();<br>
}<br>
<br>
TEST_F(StringMapTest, CtorArg) {<br>
- StringMap<MoveOnly> t;<br>
- t.GetOrCreateValue("Test", Immovable());<br>
StringRef Key = "Test";<br>
StringMapEntry<MoveOnly>::Create(Key, Immovable())<br>
->Destroy();<br>
@@ -294,7 +292,7 @@ TEST_F(StringMapTest, CtorArg) {<br>
<br>
TEST_F(StringMapTest, MoveConstruct) {<br>
StringMap<int> A;<br>
- A.GetOrCreateValue("x", 42);<br>
+ A["x"] = 42;<br>
StringMap<int> B = std::move(A);<br>
ASSERT_EQ(A.size(), 0u);<br>
ASSERT_EQ(B.size(), 1u);<br>
@@ -339,7 +337,7 @@ struct Countable {<br>
TEST_F(StringMapTest, MoveDtor) {<br>
int InstanceCount = 0;<br>
StringMap<Countable> A;<br>
- A.GetOrCreateValue("x", Countable(42, InstanceCount));<br>
+ A.insert(std::make_pair("x", Countable(42, InstanceCount)));<br>
ASSERT_EQ(InstanceCount, 1);<br>
auto I = A.find("x");<br>
ASSERT_NE(I, A.end());<br>
<br>
Modified: llvm/trunk/utils/TableGen/CodeGenRegisters.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenRegisters.cpp?rev=222319&r1=222318&r2=222319&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenRegisters.cpp?rev=222319&r1=222318&r2=222319&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/utils/TableGen/CodeGenRegisters.cpp (original)<br>
+++ llvm/trunk/utils/TableGen/CodeGenRegisters.cpp Tue Nov 18 23:49:42 2014<br>
@@ -966,9 +966,12 @@ CodeGenRegBank::CodeGenRegBank(RecordKee<br>
<br>
// Compute register name map.<br>
for (unsigned i = 0, e = Registers.size(); i != e; ++i)<br>
- RegistersByName.GetOrCreateValue(<br>
- Registers[i]->TheDef->getValueAsString("AsmName"),<br>
- Registers[i]);<br>
+ // FIXME: This could just be RegistersByName[name] = register, except that<br>
+ // causes some failures in MIPS - perhaps they have duplicate register name<br>
+ // entries? (or maybe there's a reason for it - I don't know much about this<br>
+ // code, just drive-by refactoring)<br>
+ RegistersByName.insert(std::make_pair(<br>
+ Registers[i]->TheDef->getValueAsString("AsmName"), Registers[i]));<br>
<br>
// Precompute all sub-register maps.<br>
// This will create Composite entries for all inferred sub-register indices.<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>