diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2012-01-23 03:41:53 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2012-01-23 03:41:53 +0000 |
commit | abf456e32037a39a3f8e95cc3ec3a0435f3800d3 (patch) | |
tree | e7dced48b945e3998d25a4fc069b3946dff6ddf4 /llvm/lib/Archive/ArchiveReader.cpp | |
parent | 94e746d5e502d13e39b71cd09d87daf93b441985 (diff) | |
download | llvm-abf456e32037a39a3f8e95cc3ec3a0435f3800d3.zip llvm-abf456e32037a39a3f8e95cc3ec3a0435f3800d3.tar.gz llvm-abf456e32037a39a3f8e95cc3ec3a0435f3800d3.tar.bz2 |
The iteration order over a std::set<Module*> depends on the addresses of the
modules. Avoid that to make the order the linker sees the modules deterministic.
llvm-svn: 148676
Diffstat (limited to 'llvm/lib/Archive/ArchiveReader.cpp')
-rw-r--r-- | llvm/lib/Archive/ArchiveReader.cpp | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/llvm/lib/Archive/ArchiveReader.cpp b/llvm/lib/Archive/ArchiveReader.cpp index eef6fe0..0c89baa 100644 --- a/llvm/lib/Archive/ArchiveReader.cpp +++ b/llvm/lib/Archive/ArchiveReader.cpp @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "ArchiveInternals.h" +#include "llvm/ADT/SmallPtrSet.h" #include "llvm/Bitcode/ReaderWriter.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Module.h" @@ -504,7 +505,7 @@ Archive::findModuleDefiningSymbol(const std::string& symbol, // Modules that define those symbols. bool Archive::findModulesDefiningSymbols(std::set<std::string>& symbols, - std::set<Module*>& result, + SmallVectorImpl<Module*>& result, std::string* error) { if (!mapfile || !base) { if (error) @@ -569,21 +570,22 @@ Archive::findModulesDefiningSymbols(std::set<std::string>& symbols, // At this point we have a valid symbol table (one way or another) so we // just use it to quickly find the symbols requested. + SmallPtrSet<Module*, 16> Added; for (std::set<std::string>::iterator I=symbols.begin(), - E=symbols.end(); I != E;) { + E=symbols.end(); I != E; ++I) { // See if this symbol exists Module* m = findModuleDefiningSymbol(*I,error); - if (m) { - // The symbol exists, insert the Module into our result, duplicates will - // be ignored. - result.insert(m); - - // Remove the symbol now that its been resolved, being careful to - // post-increment the iterator. - symbols.erase(I++); - } else { - ++I; - } + if (!m) + continue; + bool NewMember = Added.insert(m); + if (!NewMember) + continue; + + // The symbol exists, insert the Module into our result. + result.push_back(m); + + // Remove the symbol now that its been resolved. + symbols.erase(I); } return true; } |