[LLVMbugs] [Bug 5720] New: aliases with internal linkage don't work very well

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Tue Dec 8 09:46:38 PST 2009


http://llvm.org/bugs/show_bug.cgi?id=5720

           Summary: aliases with internal linkage don't work very well
           Product: new-bugs
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: baldrick at free.fr
                CC: llvmbugs at cs.uiuc.edu


Created an attachment (id=3924)
 --> (http://llvm.org/bugs/attachment.cgi?id=3924)
fpcmp.ll

If an alias A with internal linkage points to a symbol S with linkonce linkage,
then if the linker throws away the copy of S it is pointing to then you can get
a
link-time error, of the sort "A referenced in section .text, defined in
discarded
section .B.section".  What would be convenient is for this situation to behave
exactly the same as you would get by replacing all uses of A by B everywhere.

It is true that aliases with internal linkage are in some sense pointless -
because you can just RAUW+delete them, and indeed GlobalOpt does this
(probably the constant folder should fold them too).  However there are also
advantages to allowing them - for example the Internalize pass can produce
them, and it looks like they are convenient for llvm-gcc (ok, dragonegg) in
some circumstances - and you can't always rely on GlobalOpt or the constant
folder being run.

I suggest teaching codegen to use the aliasee B whenever the alias A has
internal linkage, and not output aliases with internal linkage.  This
effectively results in RAUW A with B at codegen time.  It also avoids
requiring support from linkers etc for this odd sort of alias.

As for the testcase, do:

llc CommandLine.ll && llc fpcmp.ll && g++ -o fpcmp fpcmp.s CommandLine.s
`llvm-config --libs`

and observe how it fails to link:
`llvm::cl::desc::desc(char const*)' referenced in section `.text' of
/tmp/cc2rAgh5.o: defined in discarded section
`.gnu.linkonce.t._ZN4llvm2cl4descC2EPKc' of /tmp/cc2rAgh5.o
...

fpcmp attached here, will attach CommandLine.ll later.


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list