[PATCH] Reload undefined atoms to use possibly new undefines.

Rui Ueyama ruiu at google.com
Tue Nov 12 22:22:09 PST 2013

As Resolver tries to resolve all undefined atoms, it loads new files. The new
files can contain any kind of atoms, namely, defined, undefined and shared. It's
possible that there's a file that contains the same undefined atom that's being
resolved now in the Resolver's for-loop.

A new undefined atom may have different fallback atom from the previous one.
Currently, such new fallback atom definitions are ignored because although
the new atom is stored to the symbol table, it's not used by Resolver. This
patch fixes that issue by reloading undefined atoms, so that Resolver will
always do based on the most recent state of the symbol table.

There's no performance penalty introduced by this patch -- just in case if you
are wondering. isDefined() uses findByName internally, so the cost is the same.



Index: lib/Core/Resolver.cpp
--- lib/Core/Resolver.cpp
+++ lib/Core/Resolver.cpp
@@ -166,7 +166,10 @@
       // If the undefined symbol has an alternative name, try to resolve the
       // symbol with the name to give it a second chance. This feature is used
       // for COFF "weak external" symbol.
-      if (!_symbolTable.isDefined(undefName)) {
+      const Atom *maybeUndefAtom = _symbolTable.findByName(undefName);
+      assert(maybeUndefAtom);
+      if (const UndefinedAtom *undefAtom = dyn_cast<const UndefinedAtom>(
+              maybeUndefAtom)) {
         if (const UndefinedAtom *fallbackUndefAtom = undefAtom->fallback()) {
           _symbolTable.addReplacement(undefAtom, fallbackUndefAtom);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2162.1.patch
Type: text/x-patch
Size: 830 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131112/71431daf/attachment.bin>

More information about the llvm-commits mailing list