<div dir="ltr">PIng.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Nov 12, 2013 at 10:22 PM, Rui Ueyama <span dir="ltr"><<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">As Resolver tries to resolve all undefined atoms, it loads new files. The new<br>
files can contain any kind of atoms, namely, defined, undefined and shared. It's<br>
possible that there's a file that contains the same undefined atom that's being<br>
resolved now in the Resolver's for-loop.<br>
<br>
A new undefined atom may have different fallback atom from the previous one.<br>
Currently, such new fallback atom definitions are ignored because although<br>
the new atom is stored to the symbol table, it's not used by Resolver. This<br>
patch fixes that issue by reloading undefined atoms, so that Resolver will<br>
always do based on the most recent state of the symbol table.<br>
<br>
There's no performance penalty introduced by this patch -- just in case if you<br>
are wondering. isDefined() uses findByName internally, so the cost is the same.<br>
<br>
<a href="http://llvm-reviews.chandlerc.com/D2162" target="_blank">http://llvm-reviews.chandlerc.com/D2162</a><br>
<br>
Files:<br>
  lib/Core/Resolver.cpp<br>
<br>
Index: lib/Core/Resolver.cpp<br>
===================================================================<br>
--- lib/Core/Resolver.cpp<br>
+++ lib/Core/Resolver.cpp<br>
@@ -166,7 +166,10 @@<br>
       // If the undefined symbol has an alternative name, try to resolve the<br>
       // symbol with the name to give it a second chance. This feature is used<br>
       // for COFF "weak external" symbol.<br>
-      if (!_symbolTable.isDefined(undefName)) {<br>
+      const Atom *maybeUndefAtom = _symbolTable.findByName(undefName);<br>
+      assert(maybeUndefAtom);<br>
+      if (const UndefinedAtom *undefAtom = dyn_cast<const UndefinedAtom>(<br>
+              maybeUndefAtom)) {<br>
         if (const UndefinedAtom *fallbackUndefAtom = undefAtom->fallback()) {<br>
           _symbolTable.addReplacement(undefAtom, fallbackUndefAtom);<br>
           _symbolTable.add(*fallbackUndefAtom);<br>
</blockquote></div><br></div>