[PATCH] Use an 'l' prefix when an 'L' prefix would produce an invalid MachO

Kostya Serebryany kcc at google.com
Sun Feb 9 08:49:16 PST 2014


+glider
Is this related to http://llvm.org/bugs/show_bug.cgi?id=17976 ?


On Sun, Feb 9, 2014 at 8:42 PM, Rafael Espíndola <rafael.espindola at gmail.com
> wrote:

> CCing Chris and Nick. I could not find them on
> http://llvm-reviews.chandlerc.com.
>
> The main question for Chris is if he is OK with this direction for
> fixing PR18743 or if he would prefer us to err on that IR.
>
> For Nick it is if there are any missing cases in
> isSectionAtomizableBySymbols.
>
> On 9 February 2014 11:38, Rafael Ávila de Espíndola
> <rafael.espindola at gmail.com> wrote:
> > rafael added you to the CC list for the revision "Use an 'l' prefix when
> an 'L' prefix would produce an invalid MachO".
> >
> > Hi grosbach,
> >
> > Fix PR18743.
> >
> > Given the perfectly valid IR
> >
> > @foo = private constant i32 42
> >
> > llvm currently produces an invalid MachO:
> >
> >         .section        __TEXT,__const
> > L_foo:                                  ## @foo
> >         .asciz  "abc"
> >
> > It is invalid because __TEXT,__const is atomized via symbols, and L_foo
> will not be visible to the linker causing an invalid atomization.
> >
> > This is a pretty big foot gun that has hit asan in the past and is
> likely to hit FE authors. Given that there is no general purpose section
> that is not atomized by symbols, the only two options I can see are
> >
> > * Reject this IR at codegen if targeting MachO
> > * Produce a symbol using an 'l' prefix instead.
> >
> > The second option is quiet a bit friendlier to users, so I tried to
> implement it first.
> >
> > What this patch does is
> > * Add a CannotUsePrivateLabel to the Mangler getNameWithPrefix. This is
> a small failure in the goal of having an IR GlobalValue map directly to a
> name, but it is OK since only applies to private labels, which don't need
> to be handled by llvm-ar or llvm-nm (which are going to be the two users of
> the Mangler that don't link with target).
> > * Add a isSectionAtomizableBySymbols to TargetLoweringObjectFileImpl.
> This contains the logic for deciding if putting a L label in a section
> would break it.
> > * Add a getNameWithPrefix to TargetMachine. It is a convenient spot for
> using isSectionAtomizableBySymbols.
> > * Pass a TM via a few callers so that they can use TM::getNameWithPrefix.
> >
> >
> >
> > http://llvm-reviews.chandlerc.com/D2727
> >
> > Files:
> >   include/llvm/CodeGen/AsmPrinter.h
> >   include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
> >   include/llvm/IR/Mangler.h
> >   include/llvm/Target/TargetLoweringObjectFile.h
> >   include/llvm/Target/TargetMachine.h
> >   lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> >   lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
> >   lib/CodeGen/AsmPrinter/DwarfCFIException.cpp
> >   lib/CodeGen/AsmPrinter/Win64Exception.cpp
> >   lib/CodeGen/TargetLoweringObjectFileImpl.cpp
> >   lib/ExecutionEngine/MCJIT/MCJIT.cpp
> >   lib/IR/Mangler.cpp
> >   lib/LTO/LTOCodeGenerator.cpp
> >   lib/LTO/LTOModule.cpp
> >   lib/Target/ARM/ARMTargetObjectFile.cpp
> >   lib/Target/ARM/ARMTargetObjectFile.h
> >   lib/Target/PowerPC/PPCMCInstLower.cpp
> >   lib/Target/Sparc/SparcTargetObjectFile.cpp
> >   lib/Target/Sparc/SparcTargetObjectFile.h
> >   lib/Target/TargetLoweringObjectFile.cpp
> >   lib/Target/TargetMachine.cpp
> >   lib/Target/X86/X86MCInstLower.cpp
> >   lib/Target/X86/X86TargetObjectFile.cpp
> >   lib/Target/X86/X86TargetObjectFile.h
> >   lib/Target/XCore/XCoreTargetObjectFile.cpp
> >   test/CodeGen/PowerPC/private.ll
> >   test/CodeGen/X86/2009-11-16-UnfoldMemOpBug.ll
> >   test/CodeGen/X86/pr10420.ll
> >   test/CodeGen/X86/private-2.ll
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> >
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140209/40c08623/attachment.html>


More information about the llvm-commits mailing list