[lld] r226688 - Simplify.
Rui Ueyama
ruiu at google.com
Wed Jan 21 10:54:27 PST 2015
Author: ruiu
Date: Wed Jan 21 12:54:26 2015
New Revision: 226688
URL: http://llvm.org/viewvc/llvm-project?rev=226688&view=rev
Log:
Simplify.
What we are trying to do here is to skip object files in group if
group is repeated. This code is simpler than before.
Modified:
lld/trunk/include/lld/Core/Resolver.h
lld/trunk/lib/Core/Resolver.cpp
Modified: lld/trunk/include/lld/Core/Resolver.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Resolver.h?rev=226688&r1=226687&r2=226688&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/Resolver.h (original)
+++ lld/trunk/include/lld/Core/Resolver.h Wed Jan 21 12:54:26 2015
@@ -58,7 +58,7 @@ private:
typedef std::function<void(StringRef, bool)> UndefCallback;
bool undefinesAdded(int begin, int end);
- File *getFile(int &index, bool &inGroup);
+ File *getFile(int &index);
/// \brief Add section group/.gnu.linkonce if it does not exist previously.
void maybeAddSectionGroupOrGnuLinkOnce(const DefinedAtom &atom);
Modified: lld/trunk/lib/Core/Resolver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/Resolver.cpp?rev=226688&r1=226687&r2=226688&view=diff
==============================================================================
--- lld/trunk/lib/Core/Resolver.cpp (original)
+++ lld/trunk/lib/Core/Resolver.cpp Wed Jan 21 12:54:26 2015
@@ -254,7 +254,7 @@ bool Resolver::undefinesAdded(int begin,
return false;
}
-File *Resolver::getFile(int &index, bool &inGroup) {
+File *Resolver::getFile(int &index) {
std::vector<std::unique_ptr<Node>> &inputs = _context.getNodes();
if ((size_t)index >= inputs.size())
return nullptr;
@@ -265,12 +265,10 @@ File *Resolver::getFile(int &index, bool
int size = group->getSize();
if (undefinesAdded(index - size, index)) {
index -= size;
- inGroup = true;
- return getFile(index, inGroup);
+ return getFile(index);
}
++index;
- inGroup = false;
- return getFile(index, inGroup);
+ return getFile(index);
}
return cast<FileNode>(inputs[index++].get())->getFile();
}
@@ -290,10 +288,10 @@ void Resolver::makePreloadArchiveMap() {
bool Resolver::resolveUndefines() {
ScopedTask task(getDefaultDomain(), "resolveUndefines");
int index = 0;
- bool inGroup = false;
+ std::set<File *> seen;
for (;;) {
bool undefAdded = false;
- File *file = getFile(index, inGroup);
+ File *file = getFile(index);
if (!file)
return true;
if (std::error_code ec = file->parse()) {
@@ -304,8 +302,12 @@ bool Resolver::resolveUndefines() {
file->beforeLink();
switch (file->kind()) {
case File::kindObject:
- if (inGroup)
+ // The same file may be visited more than once if the file is
+ // in --start-group and --end-group. Only library files should
+ // be processed more than once.
+ if (seen.count(file))
break;
+ seen.insert(file);
assert(!file->hasOrdinal());
file->setOrdinal(_context.getNextOrdinalAndIncrement());
undefAdded = handleFile(*file);
More information about the llvm-commits
mailing list