llvm.org GIT mirror llvm / 603d6b5
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148676 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 8 years ago
3 changed file(s) with 18 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
393393 /// @brief Look up multiple symbols in the archive.
394394 bool findModulesDefiningSymbols(
395395 std::set& symbols, ///< Symbols to be sought
396 std::set& modules, ///< The modules matching \p symbols
396 SmallVectorImpl& modules, ///< The modules matching \p symbols
397397 std::string* ErrMessage ///< Error msg storage, if non-zero
398398 );
399399
1111 //===----------------------------------------------------------------------===//
1212
1313 #include "ArchiveInternals.h"
14 #include "llvm/ADT/SmallPtrSet.h"
1415 #include "llvm/Bitcode/ReaderWriter.h"
1516 #include "llvm/Support/MemoryBuffer.h"
1617 #include "llvm/Module.h"
503504 // Modules that define those symbols.
504505 bool
505506 Archive::findModulesDefiningSymbols(std::set& symbols,
506 std::set& result,
507 SmallVectorImpl& result,
507508 std::string* error) {
508509 if (!mapfile || !base) {
509510 if (error)
568569 // At this point we have a valid symbol table (one way or another) so we
569570 // just use it to quickly find the symbols requested.
570571
572 SmallPtrSet Added;
571573 for (std::set::iterator I=symbols.begin(),
572 E=symbols.end(); I != E;) {
574 E=symbols.end(); I != E; ++I) {
573575 // See if this symbol exists
574576 Module* m = findModuleDefiningSymbol(*I,error);
575 if (m) {
576 // The symbol exists, insert the Module into our result, duplicates will
577 // be ignored.
578 result.insert(m);
579
580 // Remove the symbol now that its been resolved, being careful to
581 // post-increment the iterator.
582 symbols.erase(I++);
583 } else {
584 ++I;
585 }
577 if (!m)
578 continue;
579 bool NewMember = Added.insert(m);
580 if (!NewMember)
581 continue;
582
583 // The symbol exists, insert the Module into our result.
584 result.push_back(m);
585
586 // Remove the symbol now that its been resolved.
587 symbols.erase(I);
586588 }
587589 return true;
588590 }
139139 // Find the modules we need to link into the target module. Note that arch
140140 // keeps ownership of these modules and may return the same Module* from a
141141 // subsequent call.
142 std::set> Modules;
142 SmallVector> Modules;
143143 if (!arch->findModulesDefiningSymbols(UndefinedSymbols, Modules, &ErrMsg))
144144 return error("Cannot find symbols in '" + Filename.str() +
145145 "': " + ErrMsg);
156156 UndefinedSymbols.end());
157157
158158 // Loop over all the Modules that we got back from the archive
159 for (std::set::iterator I=Modules.begin(), E=Modules.end();
159 for (SmallVectorImpl::iterator I=Modules.begin(), E=Modules.end();
160160 I != E; ++I) {
161161
162162 // Get the module we must link in.