[llvm] r277847 - [ORC] Change LogicalDylib::LogicalModuleHandle from an iterator to an index.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 5 11:26:57 PDT 2016
Author: lhames
Date: Fri Aug 5 13:26:56 2016
New Revision: 277847
URL: http://llvm.org/viewvc/llvm-project?rev=277847&view=rev
Log:
[ORC] Change LogicalDylib::LogicalModuleHandle from an iterator to an index.
This prevents handles from being invalidated (through iterator invalidation)
when new modules are added.
No test-case yet: This bug was uncovered during work on an upcoming patch for
weak symbol support and the testcase for that feature will implicitly test for
correct behavior here.
Modified:
llvm/trunk/include/llvm/ExecutionEngine/Orc/LogicalDylib.h
Modified: llvm/trunk/include/llvm/ExecutionEngine/Orc/LogicalDylib.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/LogicalDylib.h?rev=277847&r1=277846&r2=277847&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/Orc/LogicalDylib.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/Orc/LogicalDylib.h Fri Aug 5 13:26:56 2016
@@ -46,7 +46,7 @@ private:
public:
typedef typename BaseLayerHandleList::iterator BaseLayerHandleIterator;
- typedef typename LogicalModuleList::iterator LogicalModuleHandle;
+ typedef typename LogicalModuleList::size_type LogicalModuleHandle;
LogicalDylib(BaseLayerT &BaseLayer) : BaseLayer(BaseLayer) {}
@@ -65,34 +65,35 @@ public:
LogicalModuleHandle createLogicalModule() {
LogicalModules.push_back(LogicalModule());
- return std::prev(LogicalModules.end());
+ return LogicalModules.size() - 1;
}
void addToLogicalModule(LogicalModuleHandle LMH,
BaseLayerModuleSetHandleT BaseLayerHandle) {
- LMH->BaseLayerHandles.push_back(BaseLayerHandle);
+ LogicalModules[LMH].BaseLayerHandles.push_back(BaseLayerHandle);
}
LogicalModuleResources& getLogicalModuleResources(LogicalModuleHandle LMH) {
- return LMH->Resources;
+ return LogicalModules[LMH].Resources;
}
BaseLayerHandleIterator moduleHandlesBegin(LogicalModuleHandle LMH) {
- return LMH->BaseLayerHandles.begin();
+ return LogicalModules[LMH].BaseLayerHandles.begin();
}
BaseLayerHandleIterator moduleHandlesEnd(LogicalModuleHandle LMH) {
- return LMH->BaseLayerHandles.end();
+ return LogicalModules[LMH].BaseLayerHandles.end();
}
JITSymbol findSymbolInLogicalModule(LogicalModuleHandle LMH,
const std::string &Name,
bool ExportedSymbolsOnly) {
- if (auto StubSym = LMH->Resources.findSymbol(Name, ExportedSymbolsOnly))
+ if (auto StubSym =
+ LogicalModules[LMH].Resources.findSymbol(Name, ExportedSymbolsOnly))
return StubSym;
- for (auto BLH : LMH->BaseLayerHandles)
+ for (auto BLH : LogicalModules[LMH].BaseLayerHandles)
if (auto Symbol = BaseLayer.findSymbolIn(BLH, Name, ExportedSymbolsOnly))
return Symbol;
return nullptr;
@@ -103,10 +104,10 @@ public:
if (auto Symbol = findSymbolInLogicalModule(LMH, Name, false))
return Symbol;
- for (auto LMI = LogicalModules.begin(), LME = LogicalModules.end();
- LMI != LME; ++LMI) {
- if (LMI != LMH)
- if (auto Symbol = findSymbolInLogicalModule(LMI, Name, false))
+ for (typename LogicalModuleList::size_type I = 0, E = LogicalModules.size();
+ I != E; ++I) {
+ if (I != LMH)
+ if (auto Symbol = findSymbolInLogicalModule(I, Name, false))
return Symbol;
}
@@ -114,9 +115,9 @@ public:
}
JITSymbol findSymbol(const std::string &Name, bool ExportedSymbolsOnly) {
- for (auto LMI = LogicalModules.begin(), LME = LogicalModules.end();
- LMI != LME; ++LMI)
- if (auto Sym = findSymbolInLogicalModule(LMI, Name, ExportedSymbolsOnly))
+ for (typename LogicalModuleList::size_type I = 0, E = LogicalModules.size();
+ I != E; ++I)
+ if (auto Sym = findSymbolInLogicalModule(I, Name, ExportedSymbolsOnly))
return Sym;
return nullptr;
}
@@ -126,10 +127,10 @@ public:
LogicalModuleResources*
getLogicalModuleResourcesForSymbol(const std::string &Name,
bool ExportedSymbolsOnly) {
- for (auto LMI = LogicalModules.begin(), LME = LogicalModules.end();
- LMI != LME; ++LMI)
- if (auto Sym = LMI->Resources.findSymbol(Name, ExportedSymbolsOnly))
- return &LMI->Resources;
+ for (typename LogicalModuleList::size_type I = 0, E = LogicalModules.size();
+ I != E; ++I)
+ if (auto Sym = LogicalModules[I].Resources.findSymbol(Name, ExportedSymbolsOnly))
+ return &LogicalModules[I]->Resources;
return nullptr;
}
More information about the llvm-commits
mailing list