Fix LTO unreferenced symbol bug due to alias renaming

Yin Ma via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 7 12:28:08 PST 2016


Hi, 

 

After 18f201b4db339145af8f340196943ef57b9c8d9f from Rafael was merged in, we
are experiencing 

unreferenced symbol in several LTO programs. I analyzed the problem and find
because 18f201 patch 

tries to discard the aliasee by renaming it. However, it will create a
problem

If the renaming happens for external functions, where non byte code may
reference to the original

name and cause unreferenced symbol at the end.

 

So, we have to perform forceRenaming like before without 18f201 for those
symbols in ShouldLink.

Like this to force those global symbols which may expose to other module to
be the original name.

 

diff --git a/lib/Linker/IRMover.cpp b/lib/Linker/IRMover.cpp

index 16de0ec..68c3346 100644

--- a/lib/Linker/IRMover.cpp

+++ b/lib/Linker/IRMover.cpp

@@ -1077,7 +1077,7 @@ Constant *IRLinker::linkGlobalValueProto(GlobalValue
*SGV, bool ForAlias) {

       return nullptr;

     NewGV = copyGlobalValueProto(SGV, ShouldLink);

-    if (!ForAlias)

+    if (ShouldLink || !ForAlias)

       forceRenaming(NewGV, SGV->getName());

   }

   if (ShouldLink || ForAlias) {

 

Please review.

 

Thanks,

 

Yin 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160107/b6dc8e49/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: i.diff
Type: application/octet-stream
Size: 63544 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160107/b6dc8e49/attachment.obj>


More information about the llvm-commits mailing list