[llvm] r201608 - Fix PR18743.

Daniel Jasper djasper at google.com
Wed Feb 19 04:33:05 PST 2014


I have looked quite a bit at this, but (not being familiar with the linker
at all), I am having a hard time coming up with a proper fix. Thus, rolled
this back in r201669.

The stack trace I received is:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff5f9dcff in llvm::MCContext::getELFSection (this=0x0,
Section=..., Type=1, Flags=50, Kind=..., EntrySize=0, Group=...) at
llvm/lib/MC/MCContext.cpp:249
249  if (ELFUniquingMap == 0)
(gdb) bt
#0  0x00007ffff5f9dcff in llvm::MCContext::getELFSection (this=0x0,
Section=..., Type=1, Flags=50, Kind=..., EntrySize=0, Group=...) at
llvm/lib/MC/MCContext.cpp:249
#1  0x00007ffff5f9dcb5 in llvm::MCContext::getELFSection (this=0x0,
Section=..., Type=1, Flags=50, Kind=...) at llvm/lib/MC/MCContext.cpp:243
#2  0x00007ffff5ad81f7 in
llvm::TargetLoweringObjectFileELF::SelectSectionForGlobal (this=0x807e70,
GV=0x80a338, Kind=..., Mang=..., TM=...) at
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp:291
#3  0x00007ffff5f3621d in llvm::TargetLoweringObjectFile::SectionForGlobal
(this=0x807e70, GV=0x80a338, Kind=..., Mang=..., TM=...) at
llvm/lib/Target/TargetLoweringObjectFile.cpp:268
#4  0x00007ffff5ad6279 in llvm::TargetLoweringBase::getNameWithPrefix
(this=0x8140b8, Name=..., GV=0x80a338, Mang=..., MayAlwaysUsePrivate=false)
at llvm/lib/CodeGen/TargetLoweringBase.cpp:1446
#5  0x00007ffff51ac5b1 in LTOModule::addDefinedSymbol (this=0x803c10,
def=0x80a338, isFunction=false) at llvm/lib/LTO/LTOModule.cpp:384
#6  0x00007ffff51ac2f0 in LTOModule::addDefinedDataSymbol (this=0x803c10,
v=0x80a338) at llvm/lib/LTO/LTOModule.cpp:299
#7  0x00007ffff51adb25 in LTOModule::parseSymbols (this=0x803c10,
errMsg="") at llvm/lib/LTO/LTOModule.cpp:786
#8  0x00007ffff51abbe9 in LTOModule::makeLTOModule (buffer=0x7e8560,
options=..., errMsg="") at llvm/lib/LTO/LTOModule.cpp:179
#9  0x00007ffff51ab7fd in LTOModule::makeLTOModule (mem=0x7ffff7fa8000,
length=10680, options=..., errMsg="", path=...) at
llvm/lib/LTO/LTOModule.cpp:135
#10 0x00007ffff51b2fe7 in lto_module_create_from_memory
(mem=0x7ffff7fa8000, length=10680) at llvm/tools/lto/lto.cpp:156
#11 0x00007ffff519b84e in claim_file_hook (file=0x7b23e0,
claimed=0x7fffffff72ac) at llvm/tools/gold/gold-plugin.cpp:273
#12 0x00000000005bfbcf in
gold::Plugin_manager::claim_file(gold::Input_file*, long, long,
gold::Object*) ()
#13 0x00000000005c42e6 in
gold::Read_symbols::do_read_symbols(gold::Workqueue*) ()
#14 0x00000000005c4871 in gold::Read_symbols::run(gold::Workqueue*) ()
#15 0x000000000060298f in gold::Workqueue::find_and_run_task(int) ()
#16 0x0000000000602d3a in gold::Workqueue::process(int) ()
#17 0x00000000004f7574 in main ()

So it seems like the new getNameWithPrefix() access the
TargetLoweringObjectFile's context (MCContext), which is NULL before a call
to TargetLoweringObjectFile::Initialize().

I am not sure why this doesn't happen in the tests. Either the tests don't
reproduce this behavior or there is a difference between lto.cpp (which is
used for LLVMgold) and llvm-lto.cpp (which is used in the tests).


On Wed, Feb 19, 2014 at 10:56 AM, Daniel Jasper <djasper at google.com> wrote:

> This breaks LTO, specifically the LLVMgold plugin, which starts to
> segfault. The problem is that the TargetLoweringObjectFile is used before
> being initialized. I'll provide more details in a few minutes.
>
>
>
> On Tue, Feb 18, 2014 at 11:24 PM, Rafael Espindola <
> rafael.espindola at gmail.com> wrote:
>
>> Author: rafael
>> Date: Tue Feb 18 16:24:57 2014
>> New Revision: 201608
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=201608&view=rev
>> Log:
>> Fix PR18743.
>>
>> The IR
>> @foo = private constant i32 42
>>
>> is valid, but before this patch we would produce an invalid MachO from
>> it. It
>> was invalid because it would use an L label in a section where the liker
>> needs
>> the labels in order to atomize it.
>>
>> One way of fixing it would be to just reject this IR in the backend, but
>> that
>> would not be very front end friendly.
>>
>> What this patch does is use an 'l' prefix in sections that we know the
>> linker
>> requires symbols for atomizing them. This allows frontends to just use
>> private and not worry about which sections they go to or how the linker
>> handles
>> them.
>>
>> One small issue with this strategy is that now a symbol name depends on
>> the
>> section, which is not available before codegen. This is not a problem in
>> practice. The reason is that it only happens with private linkage, which
>> will
>> be ignored by the non codegen users (llvm-nm and llvm-ar).
>>
>> Added:
>>     llvm/trunk/test/CodeGen/X86/osx-private-labels.ll
>> Modified:
>>     llvm/trunk/include/llvm/CodeGen/AsmPrinter.h
>>     llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
>>     llvm/trunk/include/llvm/IR/Mangler.h
>>     llvm/trunk/include/llvm/Target/TargetLowering.h
>>     llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h
>>     llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
>>     llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
>>     llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp
>>     llvm/trunk/lib/CodeGen/AsmPrinter/Win64Exception.cpp
>>     llvm/trunk/lib/CodeGen/TargetLoweringBase.cpp
>>     llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
>>     llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp
>>     llvm/trunk/lib/IR/Mangler.cpp
>>     llvm/trunk/lib/LTO/LTOCodeGenerator.cpp
>>     llvm/trunk/lib/LTO/LTOModule.cpp
>>     llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.cpp
>>     llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.h
>>     llvm/trunk/lib/Target/PowerPC/PPCMCInstLower.cpp
>>     llvm/trunk/lib/Target/Sparc/SparcTargetObjectFile.cpp
>>     llvm/trunk/lib/Target/Sparc/SparcTargetObjectFile.h
>>     llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp
>>     llvm/trunk/lib/Target/X86/X86MCInstLower.cpp
>>     llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp
>>     llvm/trunk/lib/Target/X86/X86TargetObjectFile.h
>>     llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.cpp
>>     llvm/trunk/test/CodeGen/PowerPC/private.ll
>>     llvm/trunk/test/CodeGen/X86/2009-11-16-UnfoldMemOpBug.ll
>>     llvm/trunk/test/CodeGen/X86/pr10420.ll
>>     llvm/trunk/test/CodeGen/X86/private-2.ll
>>
>> Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=201608&r1=201607&r2=201608&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original)
>> +++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Tue Feb 18 16:24:57 2014
>> @@ -161,6 +161,9 @@ namespace llvm {
>>      /// getCurrentSection() - Return the current section we are emitting
>> to.
>>      const MCSection *getCurrentSection() const;
>>
>> +    void getNameWithPrefix(SmallVectorImpl<char> &Name,
>> +                           const GlobalValue *GV) const;
>> +
>>      MCSymbol *getSymbol(const GlobalValue *GV) const;
>>
>>
>>  //===------------------------------------------------------------------===//
>>
>> Modified: llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h?rev=201608&r1=201607&r2=201608&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
>> (original)
>> +++ llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h Tue
>> Feb 18 16:24:57 2014
>> @@ -57,14 +57,15 @@ public:
>>
>>    /// Return an MCExpr to use for a reference to the specified type info
>> global
>>    /// variable from exception handling information.
>> -  const MCExpr *getTTypeGlobalReference(const GlobalValue *GV,
>> -                                        unsigned Encoding, Mangler &Mang,
>> -                                        MachineModuleInfo *MMI,
>> -                                        MCStreamer &Streamer) const
>> +  const MCExpr *
>> +  getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding,
>> +                          Mangler &Mang, const TargetMachine &TM,
>> +                          MachineModuleInfo *MMI, MCStreamer &Streamer)
>> const
>>        LLVM_OVERRIDE;
>>
>>    // The symbol that gets passed to .cfi_personality.
>>    MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
>> +                                    const TargetMachine &TM,
>>                                      MachineModuleInfo *MMI) const
>> LLVM_OVERRIDE;
>>
>>    void InitializeELF(bool UseInitArray_);
>> @@ -90,6 +91,9 @@ public:
>>                         Mangler &Mang, const TargetMachine &TM) const
>>        LLVM_OVERRIDE;
>>
>> +  bool isSectionAtomizableBySymbols(const MCSection &Section) const
>> +      LLVM_OVERRIDE;
>> +
>>    const MCSection *SelectSectionForGlobal(const GlobalValue *GV,
>>                                            SectionKind Kind, Mangler
>> &Mang,
>>                                            const TargetMachine &TM) const
>> @@ -105,18 +109,19 @@ public:
>>    /// This hook allows targets to selectively decide not to emit the
>>    /// UsedDirective for some symbols in llvm.used.
>>    /// FIXME: REMOVE this (rdar://7071300)
>> -  bool shouldEmitUsedDirectiveFor(const GlobalValue *GV, Mangler &Mang)
>> const
>> -      LLVM_OVERRIDE;
>> +  bool shouldEmitUsedDirectiveFor(const GlobalValue *GV, Mangler &Mang,
>> +                                  TargetMachine &TM) const LLVM_OVERRIDE;
>>
>>    /// The mach-o version of this method defaults to returning a stub
>> reference.
>> -  const MCExpr *getTTypeGlobalReference(const GlobalValue *GV,
>> -                                        unsigned Encoding, Mangler &Mang,
>> -                                        MachineModuleInfo *MMI,
>> -                                        MCStreamer &Streamer) const
>> +  const MCExpr *
>> +  getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding,
>> +                          Mangler &Mang, const TargetMachine &TM,
>> +                          MachineModuleInfo *MMI, MCStreamer &Streamer)
>> const
>>        LLVM_OVERRIDE;
>>
>>    // The symbol that gets passed to .cfi_personality.
>>    MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
>> +                                    const TargetMachine &TM,
>>                                      MachineModuleInfo *MMI) const
>> LLVM_OVERRIDE;
>>  };
>>
>>
>> Modified: llvm/trunk/include/llvm/IR/Mangler.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Mangler.h?rev=201608&r1=201607&r2=201608&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/include/llvm/IR/Mangler.h (original)
>> +++ llvm/trunk/include/llvm/IR/Mangler.h Tue Feb 18 16:24:57 2014
>> @@ -51,9 +51,10 @@ public:
>>    /// Print the appropriate prefix and the specified global variable's
>> name.
>>    /// If the global variable doesn't have a name, this fills in a unique
>> name
>>    /// for the global.
>> -  void getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV) const;
>> -  void getNameWithPrefix(SmallVectorImpl<char> &OutName,
>> -                         const GlobalValue *GV) const;
>> +  void getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV,
>> +                         bool CannotUsePrivateLabel) const;
>> +  void getNameWithPrefix(SmallVectorImpl<char> &OutName, const
>> GlobalValue *GV,
>> +                         bool CannotUsePrivateLabel) const;
>>
>>    /// Print the appropriate prefix and the specified name as the global
>> variable
>>    /// name. GVName must not be empty.
>>
>> Modified: llvm/trunk/include/llvm/Target/TargetLowering.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=201608&r1=201607&r2=201608&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/include/llvm/Target/TargetLowering.h (original)
>> +++ llvm/trunk/include/llvm/Target/TargetLowering.h Tue Feb 18 16:24:57
>> 2014
>> @@ -48,8 +48,10 @@ namespace llvm {
>>    class MachineFunction;
>>    class MachineInstr;
>>    class MachineJumpTableInfo;
>> +  class Mangler;
>>    class MCContext;
>>    class MCExpr;
>> +  class MCSymbol;
>>    template<typename T> class SmallVectorImpl;
>>    class DataLayout;
>>    class TargetRegisterClass;
>> @@ -1335,6 +1337,10 @@ public:
>>      return LibcallCallingConvs[Call];
>>    }
>>
>> +  void getNameWithPrefix(SmallVectorImpl<char> &Name, const GlobalValue
>> *GV,
>> +                         Mangler &Mang) const;
>> +  MCSymbol *getSymbol(const GlobalValue *GV, Mangler &Mang) const;
>> +
>>  private:
>>    const TargetMachine &TM;
>>    const DataLayout *DL;
>>
>> Modified: llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h?rev=201608&r1=201607&r2=201608&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h (original)
>> +++ llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h Tue Feb 18
>> 16:24:57 2014
>> @@ -71,8 +71,8 @@ public:
>>    /// This hook allows targets to selectively decide not to emit the
>>    /// UsedDirective for some symbols in llvm.used.
>>    /// FIXME: REMOVE this (rdar://7071300)
>> -  virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV,
>> -                                          Mangler &Mang) const {
>> +  virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV, Mangler
>> &Mang,
>> +                                          TargetMachine &TM) const {
>>      return GV != 0;
>>    }
>>
>> @@ -117,25 +117,22 @@ public:
>>
>>    /// Return an MCExpr to use for a reference to the specified global
>> variable
>>    /// from exception handling information.
>> -  virtual const MCExpr *getTTypeGlobalReference(const GlobalValue *GV,
>> -                                                unsigned Encoding,
>> -                                                Mangler &Mang,
>> -                                                MachineModuleInfo *MMI,
>> -                                                MCStreamer &Streamer)
>> const;
>> -
>> -  /// Return the MCSymbol for the specified global value. This symbol is
>> the
>> -  /// main label that is the address of the global
>> -  MCSymbol *getSymbol(const GlobalValue *GV, Mangler &M) const;
>> +  virtual const MCExpr *
>> +  getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding,
>> +                          Mangler &Mang, const TargetMachine &TM,
>> +                          MachineModuleInfo *MMI, MCStreamer &Streamer)
>> const;
>>
>>    /// Return the MCSymbol for a private symbol with global value name as
>> its
>>    /// base, with the specified suffix.
>>    MCSymbol *getSymbolWithGlobalValueBase(const GlobalValue *GV,
>> -                                         StringRef Suffix, Mangler &M)
>> const;
>> +                                         StringRef Suffix, Mangler &Mang,
>> +                                         const TargetMachine &TM) const;
>>
>>    // The symbol that gets passed to .cfi_personality.
>> -  virtual MCSymbol *
>> -  getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
>> -                          MachineModuleInfo *MMI) const;
>> +  virtual MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV,
>> +                                            Mangler &Mang,
>> +                                            const TargetMachine &TM,
>> +                                            MachineModuleInfo *MMI)
>> const;
>>
>>    const MCExpr *
>>    getTTypeReference(const MCSymbolRefExpr *Sym, unsigned Encoding,
>> @@ -157,10 +154,17 @@ public:
>>    virtual const MCExpr *getDebugThreadLocalSymbol(const MCSymbol *Sym)
>> const;
>>
>>    virtual const MCExpr *
>> -  getExecutableRelativeSymbol(const ConstantExpr *CE, Mangler &Mang)
>> const {
>> +  getExecutableRelativeSymbol(const ConstantExpr *CE, Mangler &Mang,
>> +                              const TargetMachine &TM) const {
>>      return 0;
>>    }
>>
>> +  /// \brief True if the section is atomized using the symbols in it.
>> +  /// This is false if the section is not atomized at all (most ELF
>> sections) or
>> +  /// if it is atomized based on its contents (MachO' __TEXT,__cstring
>> for
>> +  /// example).
>> +  virtual bool isSectionAtomizableBySymbols(const MCSection &Section)
>> const;
>> +
>>  protected:
>>    virtual const MCSection *
>>    SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
>>
>> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=201608&r1=201607&r2=201608&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
>> +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Tue Feb 18 16:24:57
>> 2014
>> @@ -311,8 +311,13 @@ void AsmPrinter::EmitLinkage(const Globa
>>    llvm_unreachable("Unknown linkage type!");
>>  }
>>
>> +void AsmPrinter::getNameWithPrefix(SmallVectorImpl<char> &Name,
>> +                                   const GlobalValue *GV) const {
>> +  TM.getTargetLowering()->getNameWithPrefix(Name, GV, *Mang);
>> +}
>> +
>>  MCSymbol *AsmPrinter::getSymbol(const GlobalValue *GV) const {
>> -  return getObjFileLowering().getSymbol(GV, *Mang);
>> +  return TM.getTargetLowering()->getSymbol(GV, *Mang);
>>  }
>>
>>  /// EmitGlobalVariable - Emit the specified global variable to the .s
>> file.
>> @@ -1369,7 +1374,7 @@ void AsmPrinter::EmitLLVMUsedList(const
>>    for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) {
>>      const GlobalValue *GV =
>>
>>  dyn_cast<GlobalValue>(InitList->getOperand(i)->stripPointerCasts());
>> -    if (GV && getObjFileLowering().shouldEmitUsedDirectiveFor(GV, *Mang))
>> +    if (GV && getObjFileLowering().shouldEmitUsedDirectiveFor(GV, *Mang,
>> TM))
>>        OutStreamer.EmitSymbolAttribute(getSymbol(GV), MCSA_NoDeadStrip);
>>    }
>>  }
>> @@ -1574,7 +1579,8 @@ static const MCExpr *lowerConstant(const
>>    }
>>
>>    if (const MCExpr *RelocExpr =
>> -          AP.getObjFileLowering().getExecutableRelativeSymbol(CE,
>> *AP.Mang))
>> +          AP.getObjFileLowering().getExecutableRelativeSymbol(CE,
>> *AP.Mang,
>> +                                                              AP.TM))
>>      return RelocExpr;
>>
>>    switch (CE->getOpcode()) {
>> @@ -2103,7 +2109,8 @@ MCSymbol *AsmPrinter::GetJTSetSymbol(uns
>>
>>  MCSymbol *AsmPrinter::getSymbolWithGlobalValueBase(const GlobalValue *GV,
>>                                                     StringRef Suffix)
>> const {
>> -  return getObjFileLowering().getSymbolWithGlobalValueBase(GV, Suffix,
>> *Mang);
>> +  return getObjFileLowering().getSymbolWithGlobalValueBase(GV, Suffix,
>> *Mang,
>> +                                                           TM);
>>  }
>>
>>  /// GetExternalSymbolSymbol - Return the MCSymbol for the specified
>>
>> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp?rev=201608&r1=201607&r2=201608&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp (original)
>> +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp Tue Feb 18
>> 16:24:57 2014
>> @@ -143,7 +143,7 @@ void AsmPrinter::EmitTTypeReference(cons
>>      const TargetLoweringObjectFile &TLOF = getObjFileLowering();
>>
>>      const MCExpr *Exp =
>> -        TLOF.getTTypeGlobalReference(GV, Encoding, *Mang, MMI,
>> OutStreamer);
>> +        TLOF.getTTypeGlobalReference(GV, Encoding, *Mang, TM, MMI,
>> OutStreamer);
>>      OutStreamer.EmitValue(Exp, GetSizeOfEncodedValue(Encoding));
>>    } else
>>      OutStreamer.EmitIntValue(0, GetSizeOfEncodedValue(Encoding));
>>
>> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp?rev=201608&r1=201607&r2=201608&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp (original)
>> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp Tue Feb 18
>> 16:24:57 2014
>> @@ -119,7 +119,8 @@ void DwarfCFIException::beginFunction(co
>>    if (!shouldEmitPersonality)
>>      return;
>>
>> -  const MCSymbol *Sym = TLOF.getCFIPersonalitySymbol(Per, *Asm->Mang,
>> MMI);
>> +  const MCSymbol *Sym =
>> +      TLOF.getCFIPersonalitySymbol(Per, *Asm->Mang, Asm->TM, MMI);
>>    Asm->OutStreamer.EmitCFIPersonality(Sym, PerEncoding);
>>
>>    Asm->OutStreamer.EmitDebugLabel
>>
>> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/Win64Exception.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/Win64Exception.cpp?rev=201608&r1=201607&r2=201608&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/CodeGen/AsmPrinter/Win64Exception.cpp (original)
>> +++ llvm/trunk/lib/CodeGen/AsmPrinter/Win64Exception.cpp Tue Feb 18
>> 16:24:57 2014
>> @@ -101,7 +101,8 @@ void Win64Exception::endFunction(const M
>>    if (shouldEmitPersonality) {
>>      const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
>>      const Function *Per =
>> MMI->getPersonalities()[MMI->getPersonalityIndex()];
>> -    const MCSymbol *Sym = TLOF.getCFIPersonalitySymbol(Per, *Asm->Mang,
>> MMI);
>> +    const MCSymbol *Sym =
>> +        TLOF.getCFIPersonalitySymbol(Per, *Asm->Mang, Asm->TM, MMI);
>>
>>      Asm->OutStreamer.PushSection();
>>      Asm->OutStreamer.EmitWin64EHHandlerData();
>>
>> Modified: llvm/trunk/lib/CodeGen/TargetLoweringBase.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringBase.cpp?rev=201608&r1=201607&r2=201608&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/CodeGen/TargetLoweringBase.cpp (original)
>> +++ llvm/trunk/lib/CodeGen/TargetLoweringBase.cpp Tue Feb 18 16:24:57 2014
>> @@ -24,7 +24,9 @@
>>  #include "llvm/IR/DataLayout.h"
>>  #include "llvm/IR/DerivedTypes.h"
>>  #include "llvm/IR/GlobalVariable.h"
>> +#include "llvm/IR/Mangler.h"
>>  #include "llvm/MC/MCAsmInfo.h"
>> +#include "llvm/MC/MCContext.h"
>>  #include "llvm/MC/MCExpr.h"
>>  #include "llvm/Support/CommandLine.h"
>>  #include "llvm/Support/ErrorHandling.h"
>> @@ -1426,3 +1428,29 @@ bool TargetLoweringBase::isLegalAddressi
>>
>>    return true;
>>  }
>> +
>> +void TargetLoweringBase::getNameWithPrefix(SmallVectorImpl<char> &Name,
>> +                                           const GlobalValue *GV,
>> +                                           Mangler &Mang) const {
>> +  if (!GV->hasPrivateLinkage()) {
>> +    // Simple case: If GV is not private, it is not important to find
>> out if
>> +    // private labels are legal in this case or not.
>> +    Mang.getNameWithPrefix(Name, GV, false);
>> +    return;
>> +  }
>> +  SectionKind GVKind =
>> +    TargetLoweringObjectFile::getKindForGlobal(GV, getTargetMachine());
>> +  const TargetLoweringObjectFile &TLOF = getObjFileLowering();
>> +  const MCSection *TheSection =
>> +    TLOF.SectionForGlobal(GV, GVKind, Mang, getTargetMachine());
>> +  bool CannotUsePrivateLabel =
>> TLOF.isSectionAtomizableBySymbols(*TheSection);
>> +  Mang.getNameWithPrefix(Name, GV, CannotUsePrivateLabel);
>> +}
>> +
>> +MCSymbol *TargetLoweringBase::getSymbol(const GlobalValue *GV,
>> +                                        Mangler &Mang) const {
>> +  SmallString<60> NameStr;
>> +  getNameWithPrefix(NameStr, GV, Mang);
>> +  const TargetLoweringObjectFile &TLOF = getObjFileLowering();
>> +  return TLOF.getContext().GetOrCreateSymbol(NameStr.str());
>> +}
>>
>> Modified: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp?rev=201608&r1=201607&r2=201608&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (original)
>> +++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp Tue Feb 18
>> 16:24:57 2014
>> @@ -36,6 +36,7 @@
>>  #include "llvm/Support/ErrorHandling.h"
>>  #include "llvm/Support/raw_ostream.h"
>>  #include "llvm/Target/TargetMachine.h"
>> +#include "llvm/Target/TargetLowering.h"
>>  using namespace llvm;
>>  using namespace dwarf;
>>
>> @@ -43,19 +44,18 @@ using namespace dwarf;
>>  //                                  ELF
>>
>>  //===----------------------------------------------------------------------===//
>>
>> -MCSymbol *
>> -TargetLoweringObjectFileELF::getCFIPersonalitySymbol(const GlobalValue
>> *GV,
>> -                                                     Mangler &Mang,
>> -                                                MachineModuleInfo *MMI)
>> const {
>> +MCSymbol *TargetLoweringObjectFileELF::getCFIPersonalitySymbol(
>> +    const GlobalValue *GV, Mangler &Mang, const TargetMachine &TM,
>> +    MachineModuleInfo *MMI) const {
>>    unsigned Encoding = getPersonalityEncoding();
>>    switch (Encoding & 0x70) {
>>    default:
>>      report_fatal_error("We do not support this DWARF encoding yet!");
>>    case dwarf::DW_EH_PE_absptr:
>> -    return getSymbol(GV, Mang);
>> +    return TM.getTargetLowering()->getSymbol(GV, Mang);
>>    case dwarf::DW_EH_PE_pcrel: {
>>      return getContext().GetOrCreateSymbol(StringRef("DW.ref.") +
>> -                                          getSymbol(GV,
>> Mang)->getName());
>> +                        TM.getTargetLowering()->getSymbol(GV,
>> Mang)->getName());
>>    }
>>    }
>>  }
>> @@ -89,18 +89,19 @@ void TargetLoweringObjectFileELF::emitPe
>>
>>  const MCExpr *TargetLoweringObjectFileELF::getTTypeGlobalReference(
>>      const GlobalValue *GV, unsigned Encoding, Mangler &Mang,
>> -    MachineModuleInfo *MMI, MCStreamer &Streamer) const {
>> +    const TargetMachine &TM, MachineModuleInfo *MMI,
>> +    MCStreamer &Streamer) const {
>>
>>    if (Encoding & dwarf::DW_EH_PE_indirect) {
>>      MachineModuleInfoELF &ELFMMI =
>> MMI->getObjFileInfo<MachineModuleInfoELF>();
>>
>> -    MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, ".DW.stub", Mang);
>> +    MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, ".DW.stub", Mang,
>> TM);
>>
>>      // Add information about the stub reference to ELFMMI so that the
>> stub
>>      // gets emitted by the asmprinter.
>>      MachineModuleInfoImpl::StubValueTy &StubSym =
>> ELFMMI.getGVStubEntry(SSym);
>>      if (StubSym.getPointer() == 0) {
>> -      MCSymbol *Sym = getSymbol(GV, Mang);
>> +      MCSymbol *Sym = TM.getTargetLowering()->getSymbol(GV, Mang);
>>        StubSym = MachineModuleInfoImpl::StubValueTy(Sym,
>> !GV->hasLocalLinkage());
>>      }
>>
>> @@ -109,8 +110,8 @@ const MCExpr *TargetLoweringObjectFileEL
>>                          Encoding & ~dwarf::DW_EH_PE_indirect, Streamer);
>>    }
>>
>> -  return TargetLoweringObjectFile::getTTypeGlobalReference(GV, Encoding,
>> Mang,
>> -                                                           MMI,
>> Streamer);
>> +  return TargetLoweringObjectFile::
>> +    getTTypeGlobalReference(GV, Encoding, Mang, TM, MMI, Streamer);
>>  }
>>
>>  static SectionKind
>> @@ -195,10 +196,9 @@ getELFSectionFlags(SectionKind K) {
>>    return Flags;
>>  }
>>
>> -
>> -const MCSection *TargetLoweringObjectFileELF::
>> -getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
>> -                         Mangler &Mang, const TargetMachine &TM) const {
>> +const MCSection *TargetLoweringObjectFileELF::getExplicitSectionGlobal(
>> +    const GlobalValue *GV, SectionKind Kind, Mangler &Mang,
>> +    const TargetMachine &TM) const {
>>    StringRef SectionName = GV->getSection();
>>
>>    // Infer section flags from the section name if we can.
>> @@ -248,7 +248,7 @@ SelectSectionForGlobal(const GlobalValue
>>      Prefix = getSectionPrefixForGlobal(Kind);
>>
>>      SmallString<128> Name(Prefix, Prefix+strlen(Prefix));
>> -    MCSymbol *Sym = getSymbol(GV, Mang);
>> +    MCSymbol *Sym = TM.getTargetLowering()->getSymbol(GV, Mang);
>>      Name.append(Sym->getName().begin(), Sym->getName().end());
>>      StringRef Group = "";
>>      unsigned Flags = getELFSectionFlags(Kind);
>> @@ -487,9 +487,9 @@ emitModuleFlags(MCStreamer &Streamer,
>>    Streamer.AddBlankLine();
>>  }
>>
>> -const MCSection *TargetLoweringObjectFileMachO::
>> -getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
>> -                         Mangler &Mang, const TargetMachine &TM) const {
>> +const MCSection *TargetLoweringObjectFileMachO::getExplicitSectionGlobal(
>> +    const GlobalValue *GV, SectionKind Kind, Mangler &Mang,
>> +    const TargetMachine &TM) const {
>>    // Parse the section specifier and create it if valid.
>>    StringRef Segment, Section;
>>    unsigned TAA = 0, StubSize = 0;
>> @@ -526,6 +526,41 @@ getExplicitSectionGlobal(const GlobalVal
>>    return S;
>>  }
>>
>> +bool TargetLoweringObjectFileMachO::isSectionAtomizableBySymbols(
>> +    const MCSection &Section) const {
>> +    const MCSectionMachO &SMO = static_cast<const
>> MCSectionMachO&>(Section);
>> +
>> +    // Sections holding 1 byte strings are atomized based on the data
>> +    // they contain.
>> +    // Sections holding 2 byte strings require symbols in order to be
>> +    // atomized.
>> +    // There is no dedicated section for 4 byte strings.
>> +    if (SMO.getKind().isMergeable1ByteCString())
>> +      return false;
>> +
>> +    if (SMO.getSegmentName() == "__DATA" &&
>> +        SMO.getSectionName() == "__cfstring")
>> +      return false;
>> +
>> +    switch (SMO.getType()) {
>> +    default:
>> +      return true;
>> +
>> +      // These sections are atomized at the element boundaries without
>> using
>> +      // symbols.
>> +    case MCSectionMachO::S_4BYTE_LITERALS:
>> +    case MCSectionMachO::S_8BYTE_LITERALS:
>> +    case MCSectionMachO::S_16BYTE_LITERALS:
>> +    case MCSectionMachO::S_LITERAL_POINTERS:
>> +    case MCSectionMachO::S_NON_LAZY_SYMBOL_POINTERS:
>> +    case MCSectionMachO::S_LAZY_SYMBOL_POINTERS:
>> +    case MCSectionMachO::S_MOD_INIT_FUNC_POINTERS:
>> +    case MCSectionMachO::S_MOD_TERM_FUNC_POINTERS:
>> +    case MCSectionMachO::S_INTERPOSING:
>> +      return false;
>> +    }
>> +}
>> +
>>  const MCSection *TargetLoweringObjectFileMachO::
>>  SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
>>                         Mangler &Mang, const TargetMachine &TM) const {
>> @@ -606,21 +641,17 @@ TargetLoweringObjectFileMachO::getSectio
>>    return ReadOnlySection;  // .const
>>  }
>>
>> -/// shouldEmitUsedDirectiveFor - This hook allows targets to selectively
>> decide
>> -/// not to emit the UsedDirective for some symbols in llvm.used.
>> +/// This hook allows targets to selectively decide not to emit the
>> UsedDirective
>> +/// for some symbols in llvm.used.
>>  // FIXME: REMOVE this (rdar://7071300)
>> -bool TargetLoweringObjectFileMachO::
>> -shouldEmitUsedDirectiveFor(const GlobalValue *GV, Mangler &Mang) const {
>> -  /// On Darwin, internally linked data beginning with "L" or "l" does
>> not have
>> -  /// the directive emitted (this occurs in ObjC metadata).
>> -  if (!GV) return false;
>> -
>> +bool TargetLoweringObjectFileMachO::shouldEmitUsedDirectiveFor(
>> +    const GlobalValue *GV, Mangler &Mang, TargetMachine &TM) const {
>>    // Check whether the mangled name has the "Private" or "LinkerPrivate"
>> prefix.
>>    if (GV->hasLocalLinkage() && !isa<Function>(GV)) {
>>      // FIXME: ObjC metadata is currently emitted as internal symbols
>> that have
>>      // \1L and \0l prefixes on them.  Fix them to be
>> Private/LinkerPrivate and
>>      // this horrible hack can go away.
>> -    MCSymbol *Sym = getSymbol(GV, Mang);
>> +    MCSymbol *Sym = TM.getTargetLowering()->getSymbol(GV, Mang);
>>      if (Sym->getName()[0] == 'L' || Sym->getName()[0] == 'l')
>>        return false;
>>    }
>> @@ -630,14 +661,16 @@ shouldEmitUsedDirectiveFor(const GlobalV
>>
>>  const MCExpr *TargetLoweringObjectFileMachO::getTTypeGlobalReference(
>>      const GlobalValue *GV, unsigned Encoding, Mangler &Mang,
>> -    MachineModuleInfo *MMI, MCStreamer &Streamer) const {
>> +    const TargetMachine &TM, MachineModuleInfo *MMI,
>> +    MCStreamer &Streamer) const {
>>    // The mach-o version of this method defaults to returning a stub
>> reference.
>>
>>    if (Encoding & DW_EH_PE_indirect) {
>>      MachineModuleInfoMachO &MachOMMI =
>>        MMI->getObjFileInfo<MachineModuleInfoMachO>();
>>
>> -    MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr",
>> Mang);
>> +    MCSymbol *SSym =
>> +        getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr", Mang, TM);
>>
>>      // Add information about the stub reference to MachOMMI so that the
>> stub
>>      // gets emitted by the asmprinter.
>> @@ -645,7 +678,7 @@ const MCExpr *TargetLoweringObjectFileMa
>>        GV->hasHiddenVisibility() ? MachOMMI.getHiddenGVStubEntry(SSym) :
>>                                    MachOMMI.getGVStubEntry(SSym);
>>      if (StubSym.getPointer() == 0) {
>> -      MCSymbol *Sym = getSymbol(GV, Mang);
>> +      MCSymbol *Sym = TM.getTargetLowering()->getSymbol(GV, Mang);
>>        StubSym = MachineModuleInfoImpl::StubValueTy(Sym,
>> !GV->hasLocalLinkage());
>>      }
>>
>> @@ -654,24 +687,24 @@ const MCExpr *TargetLoweringObjectFileMa
>>                          Encoding & ~dwarf::DW_EH_PE_indirect, Streamer);
>>    }
>>
>> -  return TargetLoweringObjectFile::
>> -    getTTypeGlobalReference(GV, Encoding, Mang, MMI, Streamer);
>> +  return TargetLoweringObjectFile::getTTypeGlobalReference(GV, Encoding,
>> Mang,
>> +                                                           TM, MMI,
>> Streamer);
>>  }
>>
>> -MCSymbol *TargetLoweringObjectFileMachO::
>> -getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
>> -                        MachineModuleInfo *MMI) const {
>> +MCSymbol *TargetLoweringObjectFileMachO::getCFIPersonalitySymbol(
>> +    const GlobalValue *GV, Mangler &Mang, const TargetMachine &TM,
>> +    MachineModuleInfo *MMI) const {
>>    // The mach-o version of this method defaults to returning a stub
>> reference.
>>    MachineModuleInfoMachO &MachOMMI =
>>      MMI->getObjFileInfo<MachineModuleInfoMachO>();
>>
>> -  MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr",
>> Mang);
>> +  MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr",
>> Mang, TM);
>>
>>    // Add information about the stub reference to MachOMMI so that the
>> stub
>>    // gets emitted by the asmprinter.
>>    MachineModuleInfoImpl::StubValueTy &StubSym =
>> MachOMMI.getGVStubEntry(SSym);
>>    if (StubSym.getPointer() == 0) {
>> -    MCSymbol *Sym = getSymbol(GV, Mang);
>> +    MCSymbol *Sym = TM.getTargetLowering()->getSymbol(GV, Mang);
>>      StubSym = MachineModuleInfoImpl::StubValueTy(Sym,
>> !GV->hasLocalLinkage());
>>    }
>>
>> @@ -717,9 +750,9 @@ getCOFFSectionFlags(SectionKind K) {
>>    return Flags;
>>  }
>>
>> -const MCSection *TargetLoweringObjectFileCOFF::
>> -getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
>> -                         Mangler &Mang, const TargetMachine &TM) const {
>> +const MCSection *TargetLoweringObjectFileCOFF::getExplicitSectionGlobal(
>> +    const GlobalValue *GV, SectionKind Kind, Mangler &Mang,
>> +    const TargetMachine &TM) const {
>>    int Selection = 0;
>>    unsigned Characteristics = getCOFFSectionFlags(Kind);
>>    StringRef Name = GV->getSection();
>> @@ -727,7 +760,7 @@ getExplicitSectionGlobal(const GlobalVal
>>    if (GV->isWeakForLinker()) {
>>      Selection = COFF::IMAGE_COMDAT_SELECT_ANY;
>>      Characteristics |= COFF::IMAGE_SCN_LNK_COMDAT;
>> -    MCSymbol *Sym = getSymbol(GV, Mang);
>> +    MCSymbol *Sym = TM.getTargetLowering()->getSymbol(GV, Mang);
>>      COMDATSymName = Sym->getName();
>>    }
>>    return getContext().getCOFFSection(Name,
>> @@ -761,7 +794,7 @@ SelectSectionForGlobal(const GlobalValue
>>      unsigned Characteristics = getCOFFSectionFlags(Kind);
>>
>>      Characteristics |= COFF::IMAGE_SCN_LNK_COMDAT;
>> -    MCSymbol *Sym = getSymbol(GV, Mang);
>> +    MCSymbol *Sym = TM.getTargetLowering()->getSymbol(GV, Mang);
>>      return getContext().getCOFFSection(Name, Characteristics,
>>                                         Kind, Sym->getName(),
>>                                         COFF::IMAGE_COMDAT_SELECT_ANY);
>>
>> Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp?rev=201608&r1=201607&r2=201608&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp (original)
>> +++ llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp Tue Feb 18 16:24:57
>> 2014
>> @@ -27,6 +27,7 @@
>>  #include "llvm/Support/ErrorHandling.h"
>>  #include "llvm/Support/MemoryBuffer.h"
>>  #include "llvm/Support/MutexGuard.h"
>> +#include "llvm/Target/TargetLowering.h"
>>
>>  using namespace llvm;
>>
>> @@ -371,7 +372,7 @@ void *MCJIT::getPointerToFunction(Functi
>>    // load address of the symbol, not the local address.
>>    Mangler Mang(TM->getDataLayout());
>>    SmallString<128> Name;
>> -  Mang.getNameWithPrefix(Name, F);
>> +  TM->getTargetLowering()->getNameWithPrefix(Name, F, Mang);
>>    return (void*)Dyld.getSymbolLoadAddress(Name);
>>  }
>>
>>
>> Modified: llvm/trunk/lib/IR/Mangler.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Mangler.cpp?rev=201608&r1=201607&r2=201608&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/IR/Mangler.cpp (original)
>> +++ llvm/trunk/lib/IR/Mangler.cpp Tue Feb 18 16:24:57 2014
>> @@ -76,12 +76,18 @@ static void AddFastCallStdCallSuffix(raw
>>    OS << '@' << ArgWords;
>>  }
>>
>> -void Mangler::getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV)
>> const {
>> +void Mangler::getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV,
>> +                                bool CannotUsePrivateLabel) const {
>>    ManglerPrefixTy PrefixTy = Mangler::Default;
>> -  if (GV->hasPrivateLinkage())
>> -    PrefixTy = Mangler::Private;
>> -  else if (GV->hasLinkerPrivateLinkage() ||
>> GV->hasLinkerPrivateWeakLinkage())
>> +  if (GV->hasPrivateLinkage()) {
>> +    if (CannotUsePrivateLabel)
>> +      PrefixTy = Mangler::LinkerPrivate;
>> +    else
>> +      PrefixTy = Mangler::Private;
>> +  } else if (GV->hasLinkerPrivateLinkage() ||
>> +             GV->hasLinkerPrivateWeakLinkage()) {
>>      PrefixTy = Mangler::LinkerPrivate;
>> +  }
>>
>>    if (!GV->hasName()) {
>>      // Get the ID for the global, assigning a new one if we haven't got
>> one
>> @@ -134,7 +140,8 @@ void Mangler::getNameWithPrefix(raw_ostr
>>  }
>>
>>  void Mangler::getNameWithPrefix(SmallVectorImpl<char> &OutName,
>> -                                const GlobalValue *GV) const {
>> +                                const GlobalValue *GV,
>> +                                bool CannotUsePrivateLabel) const {
>>    raw_svector_ostream OS(OutName);
>> -  getNameWithPrefix(OS, GV);
>> +  getNameWithPrefix(OS, GV, CannotUsePrivateLabel);
>>  }
>>
>> Modified: llvm/trunk/lib/LTO/LTOCodeGenerator.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTOCodeGenerator.cpp?rev=201608&r1=201607&r2=201608&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/LTO/LTOCodeGenerator.cpp (original)
>> +++ llvm/trunk/lib/LTO/LTOCodeGenerator.cpp Tue Feb 18 16:24:57 2014
>> @@ -336,7 +336,7 @@ applyRestriction(GlobalValue &GV,
>>                   SmallPtrSet<GlobalValue*, 8> &AsmUsed,
>>                   Mangler &Mangler) {
>>    SmallString<64> Buffer;
>> -  Mangler.getNameWithPrefix(Buffer, &GV);
>> +  TargetMach->getTargetLowering()->getNameWithPrefix(Buffer, &GV,
>> Mangler);
>>
>>    if (GV.isDeclaration())
>>      return;
>>
>> Modified: llvm/trunk/lib/LTO/LTOModule.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTOModule.cpp?rev=201608&r1=201607&r2=201608&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/LTO/LTOModule.cpp (original)
>> +++ llvm/trunk/lib/LTO/LTOModule.cpp Tue Feb 18 16:24:57 2014
>> @@ -381,7 +381,7 @@ void LTOModule::addDefinedSymbol(const G
>>
>>    // string is owned by _defines
>>    SmallString<64> Buffer;
>> -  _mangler.getNameWithPrefix(Buffer, def);
>> +  _target->getTargetLowering()->getNameWithPrefix(Buffer, def, _mangler);
>>
>>    // set alignment part log2() can have rounding errors
>>    uint32_t align = def->getAlignment();
>> @@ -517,7 +517,7 @@ LTOModule::addPotentialUndefinedSymbol(c
>>      return;
>>
>>    SmallString<64> name;
>> -  _mangler.getNameWithPrefix(name, decl);
>> +  _target->getTargetLowering()->getNameWithPrefix(name, decl, _mangler);
>>
>>    StringMap<NameAndAttributes>::value_type &entry =
>>      _undefines.GetOrCreateValue(name);
>>
>> Modified: llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.cpp?rev=201608&r1=201607&r2=201608&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.cpp (original)
>> +++ llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.cpp Tue Feb 18 16:24:57
>> 2014
>> @@ -16,7 +16,7 @@
>>  #include "llvm/MC/MCSectionELF.h"
>>  #include "llvm/Support/Dwarf.h"
>>  #include "llvm/Support/ELF.h"
>> -#include "llvm/Target/TargetMachine.h"
>> +#include "llvm/Target/TargetLowering.h"
>>  using namespace llvm;
>>  using namespace dwarf;
>>
>> @@ -43,12 +43,12 @@ void ARMElfTargetObjectFile::Initialize(
>>
>>  const MCExpr *ARMElfTargetObjectFile::getTTypeGlobalReference(
>>      const GlobalValue *GV, unsigned Encoding, Mangler &Mang,
>> -    MachineModuleInfo *MMI, MCStreamer &Streamer) const {
>> +    const TargetMachine &TM, MachineModuleInfo *MMI,
>> +    MCStreamer &Streamer) const {
>>    assert(Encoding == DW_EH_PE_absptr && "Can handle absptr encoding
>> only");
>>
>> -  return MCSymbolRefExpr::Create(getSymbol(GV, Mang),
>> -                                 MCSymbolRefExpr::VK_ARM_TARGET2,
>> -                                 getContext());
>> +  return MCSymbolRefExpr::Create(TM.getTargetLowering()->getSymbol(GV,
>> Mang),
>> +                                 MCSymbolRefExpr::VK_ARM_TARGET2,
>> getContext());
>>  }
>>
>>  const MCExpr *ARMElfTargetObjectFile::
>>
>> Modified: llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.h?rev=201608&r1=201607&r2=201608&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.h (original)
>> +++ llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.h Tue Feb 18 16:24:57
>> 2014
>> @@ -28,10 +28,10 @@ public:
>>
>>    void Initialize(MCContext &Ctx, const TargetMachine &TM) LLVM_OVERRIDE;
>>
>> -  const MCExpr *getTTypeGlobalReference(const GlobalValue *GV,
>> -                                        unsigned Encoding, Mangler &Mang,
>> -                                        MachineModuleInfo *MMI,
>> -                                        MCStreamer &Streamer) const
>> +  const MCExpr *
>> +  getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding,
>> +                          Mangler &Mang, const TargetMachine &TM,
>> +                          MachineModuleInfo *MMI, MCStreamer &Streamer)
>> const
>>        LLVM_OVERRIDE;
>>
>>    /// \brief Describe a TLS variable address within debug info.
>>
>> Modified: llvm/trunk/lib/Target/PowerPC/PPCMCInstLower.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCMCInstLower.cpp?rev=201608&r1=201607&r2=201608&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/Target/PowerPC/PPCMCInstLower.cpp (original)
>> +++ llvm/trunk/lib/Target/PowerPC/PPCMCInstLower.cpp Tue Feb 18 16:24:57
>> 2014
>> @@ -25,7 +25,8 @@
>>  #include "llvm/MC/MCAsmInfo.h"
>>  #include "llvm/MC/MCExpr.h"
>>  #include "llvm/MC/MCInst.h"
>> -#include "llvm/Target/TargetMachine.h"
>> +#include "llvm/Target/TargetLowering.h"
>> +#include "llvm/Target/TargetLoweringObjectFile.h"
>>  using namespace llvm;
>>
>>  static MachineModuleInfoMachO &getMachOMMI(AsmPrinter &AP) {
>> @@ -34,7 +35,9 @@ static MachineModuleInfoMachO &getMachOM
>>
>>
>>  static MCSymbol *GetSymbolFromOperand(const MachineOperand &MO,
>> AsmPrinter &AP){
>> -  const DataLayout *DL = AP.TM.getDataLayout();
>> +  const TargetMachine &TM = AP.TM;
>> +  Mangler *Mang = AP.Mang;
>> +  const DataLayout *DL = TM.getDataLayout();
>>    MCContext &Ctx = AP.OutContext;
>>
>>    SmallString<128> Name;
>> @@ -51,10 +54,10 @@ static MCSymbol *GetSymbolFromOperand(co
>>
>>    if (!MO.isGlobal()) {
>>      assert(MO.isSymbol() && "Isn't a symbol reference");
>> -    AP.Mang->getNameWithPrefix(Name, MO.getSymbolName());
>> +    Mang->getNameWithPrefix(Name, MO.getSymbolName());
>>    } else {
>>      const GlobalValue *GV = MO.getGlobal();
>> -    AP.Mang->getNameWithPrefix(Name, GV);
>> +    TM.getTargetLowering()->getNameWithPrefix(Name, GV, *Mang);
>>    }
>>
>>    unsigned OrigLen = Name.size() - PrefixLen;
>>
>> Modified: llvm/trunk/lib/Target/Sparc/SparcTargetObjectFile.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/SparcTargetObjectFile.cpp?rev=201608&r1=201607&r2=201608&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/Target/Sparc/SparcTargetObjectFile.cpp (original)
>> +++ llvm/trunk/lib/Target/Sparc/SparcTargetObjectFile.cpp Tue Feb 18
>> 16:24:57 2014
>> @@ -11,23 +11,25 @@
>>  #include "MCTargetDesc/SparcMCExpr.h"
>>  #include "llvm/CodeGen/MachineModuleInfoImpls.h"
>>  #include "llvm/Support/Dwarf.h"
>> +#include "llvm/Target/TargetLowering.h"
>>
>>  using namespace llvm;
>>
>>  const MCExpr *SparcELFTargetObjectFile::getTTypeGlobalReference(
>>      const GlobalValue *GV, unsigned Encoding, Mangler &Mang,
>> -    MachineModuleInfo *MMI, MCStreamer &Streamer) const {
>> +    const TargetMachine &TM, MachineModuleInfo *MMI,
>> +    MCStreamer &Streamer) const {
>>
>>    if (Encoding & dwarf::DW_EH_PE_pcrel) {
>>      MachineModuleInfoELF &ELFMMI =
>> MMI->getObjFileInfo<MachineModuleInfoELF>();
>>
>> -    MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, ".DW.stub", Mang);
>> +    MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, ".DW.stub", Mang,
>> TM);
>>
>>      // Add information about the stub reference to ELFMMI so that the
>> stub
>>      // gets emitted by the asmprinter.
>>      MachineModuleInfoImpl::StubValueTy &StubSym =
>> ELFMMI.getGVStubEntry(SSym);
>>      if (StubSym.getPointer() == 0) {
>> -      MCSymbol *Sym = getSymbol(GV, Mang);
>> +      MCSymbol *Sym = TM.getTargetLowering()->getSymbol(GV, Mang);
>>        StubSym = MachineModuleInfoImpl::StubValueTy(Sym,
>> !GV->hasLocalLinkage());
>>      }
>>
>> @@ -37,5 +39,5 @@ const MCExpr *SparcELFTargetObjectFile::
>>    }
>>
>>    return TargetLoweringObjectFileELF::getTTypeGlobalReference(
>> -      GV, Encoding, Mang, MMI, Streamer);
>> +      GV, Encoding, Mang, TM, MMI, Streamer);
>>  }
>>
>> Modified: llvm/trunk/lib/Target/Sparc/SparcTargetObjectFile.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/SparcTargetObjectFile.h?rev=201608&r1=201607&r2=201608&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/Target/Sparc/SparcTargetObjectFile.h (original)
>> +++ llvm/trunk/lib/Target/Sparc/SparcTargetObjectFile.h Tue Feb 18
>> 16:24:57 2014
>> @@ -23,10 +23,10 @@ public:
>>      TargetLoweringObjectFileELF()
>>    {}
>>
>> -  const MCExpr *getTTypeGlobalReference(const GlobalValue *GV,
>> -                                        unsigned Encoding, Mangler &Mang,
>> -                                        MachineModuleInfo *MMI,
>> -                                        MCStreamer &Streamer) const
>> +  const MCExpr *
>> +  getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding,
>> +                          Mangler &Mang, const TargetMachine &TM,
>> +                          MachineModuleInfo *MMI, MCStreamer &Streamer)
>> const
>>        LLVM_OVERRIDE;
>>  };
>>
>>
>> Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=201608&r1=201607&r2=201608&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original)
>> +++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Tue Feb 18
>> 16:24:57 2014
>> @@ -28,6 +28,7 @@
>>  #include "llvm/Support/ErrorHandling.h"
>>  #include "llvm/Support/raw_ostream.h"
>>  #include "llvm/Target/TargetMachine.h"
>> +#include "llvm/Target/TargetLowering.h"
>>  #include "llvm/Target/TargetOptions.h"
>>  using namespace llvm;
>>
>> @@ -99,30 +100,22 @@ static bool IsNullTerminatedString(const
>>    return false;
>>  }
>>
>> -/// Return the MCSymbol for the specified global value.  This
>> -/// symbol is the main label that is the address of the global.
>> -MCSymbol *TargetLoweringObjectFile::getSymbol(const GlobalValue *GV,
>> -                                              Mangler &M) const {
>> -  SmallString<60> NameStr;
>> -  M.getNameWithPrefix(NameStr, GV);
>> -  return Ctx->GetOrCreateSymbol(NameStr.str());
>> -}
>> -
>>  MCSymbol *TargetLoweringObjectFile::getSymbolWithGlobalValueBase(
>> -    const GlobalValue *GV, StringRef Suffix, Mangler &M) const {
>> +    const GlobalValue *GV, StringRef Suffix, Mangler &Mang,
>> +    const TargetMachine &TM) const {
>>    assert(!Suffix.empty());
>>
>>    SmallString<60> NameStr;
>>    NameStr += DL->getPrivateGlobalPrefix();
>> -  M.getNameWithPrefix(NameStr, GV);
>> +  TM.getTargetLowering()->getNameWithPrefix(NameStr, GV, Mang);
>>    NameStr.append(Suffix.begin(), Suffix.end());
>>    return Ctx->GetOrCreateSymbol(NameStr.str());
>>  }
>>
>> -MCSymbol *TargetLoweringObjectFile::
>> -getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
>> -                        MachineModuleInfo *MMI) const {
>> -  return getSymbol(GV, Mang);
>> +MCSymbol *TargetLoweringObjectFile::getCFIPersonalitySymbol(
>> +    const GlobalValue *GV, Mangler &Mang, const TargetMachine &TM,
>> +    MachineModuleInfo *MMI) const {
>> +  return TM.getTargetLowering()->getSymbol(GV, Mang);
>>  }
>>
>>  void TargetLoweringObjectFile::emitPersonalityValue(MCStreamer &Streamer,
>> @@ -275,6 +268,10 @@ SectionForGlobal(const GlobalValue *GV,
>>    return SelectSectionForGlobal(GV, Kind, Mang, TM);
>>  }
>>
>> +bool TargetLoweringObjectFile::isSectionAtomizableBySymbols(
>> +    const MCSection &Section) const {
>> +  return false;
>> +}
>>
>>  // Lame default implementation. Calculate the section name for global.
>>  const MCSection *
>> @@ -312,9 +309,11 @@ TargetLoweringObjectFile::getSectionForC
>>  /// handling information.
>>  const MCExpr *TargetLoweringObjectFile::getTTypeGlobalReference(
>>      const GlobalValue *GV, unsigned Encoding, Mangler &Mang,
>> -    MachineModuleInfo *MMI, MCStreamer &Streamer) const {
>> +    const TargetMachine &TM, MachineModuleInfo *MMI,
>> +    MCStreamer &Streamer) const {
>>    const MCSymbolRefExpr *Ref =
>> -      MCSymbolRefExpr::Create(getSymbol(GV, Mang), getContext());
>> +    MCSymbolRefExpr::Create(TM.getTargetLowering()->getSymbol(GV, Mang),
>> +                            getContext());
>>
>>    return getTTypeReference(Ref, Encoding, Streamer);
>>  }
>>
>> Modified: llvm/trunk/lib/Target/X86/X86MCInstLower.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86MCInstLower.cpp?rev=201608&r1=201607&r2=201608&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/Target/X86/X86MCInstLower.cpp (original)
>> +++ llvm/trunk/lib/Target/X86/X86MCInstLower.cpp Tue Feb 18 16:24:57 2014
>> @@ -98,7 +98,7 @@ GetSymbolFromOperand(const MachineOperan
>>
>>    if (MO.isGlobal()) {
>>      const GlobalValue *GV = MO.getGlobal();
>> -    getMang()->getNameWithPrefix(Name, GV);
>> +    AsmPrinter.getNameWithPrefix(Name, GV);
>>    } else if (MO.isSymbol()) {
>>      getMang()->getNameWithPrefix(Name, MO.getSymbolName());
>>    } else if (MO.isMBB()) {
>>
>> Modified: llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp?rev=201608&r1=201607&r2=201608&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp (original)
>> +++ llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp Tue Feb 18 16:24:57
>> 2014
>> @@ -14,18 +14,20 @@
>>  #include "llvm/MC/MCExpr.h"
>>  #include "llvm/MC/MCSectionELF.h"
>>  #include "llvm/Support/Dwarf.h"
>> +#include "llvm/Target/TargetLowering.h"
>>
>>  using namespace llvm;
>>  using namespace dwarf;
>>
>>  const MCExpr *X86_64MachoTargetObjectFile::getTTypeGlobalReference(
>>      const GlobalValue *GV, unsigned Encoding, Mangler &Mang,
>> -    MachineModuleInfo *MMI, MCStreamer &Streamer) const {
>> +    const TargetMachine &TM, MachineModuleInfo *MMI,
>> +    MCStreamer &Streamer) const {
>>
>>    // On Darwin/X86-64, we can reference dwarf symbols with foo at GOTPCREL+4,
>> which
>>    // is an indirect pc-relative reference.
>>    if (Encoding & (DW_EH_PE_indirect | DW_EH_PE_pcrel)) {
>> -    const MCSymbol *Sym = getSymbol(GV, Mang);
>> +    const MCSymbol *Sym = TM.getTargetLowering()->getSymbol(GV, Mang);
>>      const MCExpr *Res =
>>        MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_GOTPCREL,
>> getContext());
>>      const MCExpr *Four = MCConstantExpr::Create(4, getContext());
>> @@ -33,13 +35,13 @@ const MCExpr *X86_64MachoTargetObjectFil
>>    }
>>
>>    return TargetLoweringObjectFileMachO::getTTypeGlobalReference(
>> -      GV, Encoding, Mang, MMI, Streamer);
>> +      GV, Encoding, Mang, TM, MMI, Streamer);
>>  }
>>
>> -MCSymbol *X86_64MachoTargetObjectFile::
>> -getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
>> -                        MachineModuleInfo *MMI) const {
>> -  return getSymbol(GV, Mang);
>> +MCSymbol *X86_64MachoTargetObjectFile::getCFIPersonalitySymbol(
>> +    const GlobalValue *GV, Mangler &Mang, const TargetMachine &TM,
>> +    MachineModuleInfo *MMI) const {
>> +  return TM.getTargetLowering()->getSymbol(GV, Mang);
>>  }
>>
>>  void
>> @@ -54,9 +56,8 @@ X86LinuxTargetObjectFile::getDebugThread
>>    return MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_DTPOFF,
>> getContext());
>>  }
>>
>> -const MCExpr *
>> -X86WindowsTargetObjectFile::getExecutableRelativeSymbol(const
>> ConstantExpr *CE,
>> -                                                        Mangler &Mang)
>> const {
>> +const MCExpr *X86WindowsTargetObjectFile::getExecutableRelativeSymbol(
>> +    const ConstantExpr *CE, Mangler &Mang, const TargetMachine &TM)
>> const {
>>    // We are looking for the difference of two symbols, need a subtraction
>>    // operation.
>>    const SubOperator *Sub = dyn_cast<SubOperator>(CE);
>> @@ -101,6 +102,7 @@ X86WindowsTargetObjectFile::getExecutabl
>>    if (GVLHS->isThreadLocal())
>>      return 0;
>>
>> -  return MCSymbolRefExpr::Create(
>> -      getSymbol(GVLHS, Mang), MCSymbolRefExpr::VK_COFF_IMGREL32,
>> getContext());
>> +  return
>> MCSymbolRefExpr::Create(TM.getTargetLowering()->getSymbol(GVLHS, Mang),
>> +                                 MCSymbolRefExpr::VK_COFF_IMGREL32,
>> +                                 getContext());
>>  }
>>
>> Modified: llvm/trunk/lib/Target/X86/X86TargetObjectFile.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetObjectFile.h?rev=201608&r1=201607&r2=201608&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/Target/X86/X86TargetObjectFile.h (original)
>> +++ llvm/trunk/lib/Target/X86/X86TargetObjectFile.h Tue Feb 18 16:24:57
>> 2014
>> @@ -20,15 +20,16 @@ namespace llvm {
>>    /// x86-64.
>>    class X86_64MachoTargetObjectFile : public
>> TargetLoweringObjectFileMachO {
>>    public:
>> -    const MCExpr *getTTypeGlobalReference(const GlobalValue *GV,
>> -                                          unsigned Encoding, Mangler
>> &Mang,
>> -                                          MachineModuleInfo *MMI,
>> -                                          MCStreamer &Streamer) const
>> +    const MCExpr *
>> +    getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding,
>> +                            Mangler &Mang, const TargetMachine &TM,
>> +                            MachineModuleInfo *MMI, MCStreamer
>> &Streamer) const
>>          LLVM_OVERRIDE;
>>
>>      // getCFIPersonalitySymbol - The symbol that gets passed to
>>      // .cfi_personality.
>>      MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV, Mangler
>> &Mang,
>> +                                      const TargetMachine &TM,
>>                                        MachineModuleInfo *MMI) const
>>          LLVM_OVERRIDE;
>>    };
>> @@ -46,7 +47,8 @@ namespace llvm {
>>    /// \brief This implementation is used for Windows targets on x86 and
>> x86-64.
>>    class X86WindowsTargetObjectFile : public TargetLoweringObjectFileCOFF
>> {
>>      const MCExpr *getExecutableRelativeSymbol(const ConstantExpr *CE,
>> -                                              Mangler &Mang) const
>> +                                              Mangler &Mang,
>> +                                              const TargetMachine &TM)
>> const
>>          LLVM_OVERRIDE;
>>    };
>>
>>
>> Modified: llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.cpp?rev=201608&r1=201607&r2=201608&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.cpp (original)
>> +++ llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.cpp Tue Feb 18
>> 16:24:57 2014
>> @@ -118,9 +118,10 @@ static unsigned getXCoreSectionFlags(Sec
>>    return Flags;
>>  }
>>
>> -const MCSection *XCoreTargetObjectFile::
>> -getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
>> -                         Mangler &Mang, const TargetMachine &TM) const {
>> +const MCSection *
>> +XCoreTargetObjectFile::getExplicitSectionGlobal(const GlobalValue *GV,
>> +                                                SectionKind Kind,
>> Mangler &Mang,
>> +                                                const TargetMachine &TM)
>> const {
>>    StringRef SectionName = GV->getSection();
>>    // Infer section flags from the section name if we can.
>>    bool IsCPRel = SectionName.startswith(".cp.");
>>
>> Modified: llvm/trunk/test/CodeGen/PowerPC/private.ll
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/private.ll?rev=201608&r1=201607&r2=201608&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/test/CodeGen/PowerPC/private.ll (original)
>> +++ llvm/trunk/test/CodeGen/PowerPC/private.ll Tue Feb 18 16:24:57 2014
>> @@ -7,22 +7,22 @@
>>  ; RUN: FileCheck --check-prefix=OSX %s
>>
>>  ; LINUX: .Lfoo:
>> -; OSX: L_foo:
>> +; OSX: l_foo:
>>  define private void @foo() nounwind {
>>          ret void
>>  }
>>
>>  define i32 @bar() nounwind {
>>  ; LINUX: bl{{.*}}.Lfoo
>> -; OSX: bl{{.*}}L_foo
>> +; OSX: bl{{.*}}l_foo
>>          call void @foo()
>>
>>  ; LINUX: lis{{.*}}.Lbaz
>> -; OSX:  lis{{.*}}L_baz
>> +; OSX:  lis{{.*}}l_baz
>>         %1 = load i32* @baz, align 4
>>          ret i32 %1
>>  }
>>
>>  ; LINUX: .Lbaz:
>> -; OSX: L_baz:
>> +; OSX: l_baz:
>>  @baz = private global i32 4
>>
>> Modified: llvm/trunk/test/CodeGen/X86/2009-11-16-UnfoldMemOpBug.ll
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2009-11-16-UnfoldMemOpBug.ll?rev=201608&r1=201607&r2=201608&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/test/CodeGen/X86/2009-11-16-UnfoldMemOpBug.ll (original)
>> +++ llvm/trunk/test/CodeGen/X86/2009-11-16-UnfoldMemOpBug.ll Tue Feb 18
>> 16:24:57 2014
>> @@ -1,7 +1,7 @@
>>  ; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=corei7 | FileCheck %s
>>  ; rdar://7396984
>>
>> - at str = private constant [28 x i8] c"xxxxxxxxxxxxxxxxxxxxxxxxxxx\00",
>> align 1
>> + at str = private unnamed_addr constant [28 x i8]
>> c"xxxxxxxxxxxxxxxxxxxxxxxxxxx\00", align 1
>>
>>  define void @t(i32 %count) ssp nounwind {
>>  entry:
>>
>> Added: llvm/trunk/test/CodeGen/X86/osx-private-labels.ll
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/osx-private-labels.ll?rev=201608&view=auto
>>
>> ==============================================================================
>> --- llvm/trunk/test/CodeGen/X86/osx-private-labels.ll (added)
>> +++ llvm/trunk/test/CodeGen/X86/osx-private-labels.ll Tue Feb 18 16:24:57
>> 2014
>> @@ -0,0 +1,71 @@
>> +; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck %s
>> +; Test all the cases where a L label is safe. Removing any entry from
>> +; TargetLoweringObjectFileMachO::isSectionAtomizableBySymbols should
>> cause
>> +; this to fail.
>> +; We also test some noteworthy cases that require an l label.
>> +
>> + at private1 = private unnamed_addr constant [4 x i8] c"zed\00"
>> +; CHECK: .section      __TEXT,__cstring,cstring_literals
>> +; CHECK-NEXT: L_private1:
>> +
>> + at private2 = private unnamed_addr constant [5 x i16] [i16 116, i16 101,
>> +                                                     i16 115, i16 116,
>> i16 0]
>> +; CHECK: .section      __TEXT,__ustring
>> +; CHECK-NEXT: .align   1
>> +; CHECK-NEXT: l_private2:
>> +
>> +; There is no dedicated 4 byte strings on MachO.
>> +
>> +%struct.NSConstantString = type { i32*, i32, i8*, i32 }
>> + at private3 = private constant %struct.NSConstantString { i32* null, i32
>> 1992, i8* null, i32 0 }, section "__DATA,__cfstring"
>> +; CHECK: .section      __DATA,__cfstring
>> +; CHECK-NEXT: .align   4
>> +; CHECK-NEXT: L_private3:
>> +
>> +; There is no dedicated 1 or 2 byte constant section on MachO.
>> +
>> + at private4 = private unnamed_addr constant i32 42
>> +; CHECK: .section      __TEXT,__literal4,4byte_literals
>> +; CHECK-NEXT: .align   2
>> +; CHECK-NEXT: L_private4:
>> +
>> + at private5 = private unnamed_addr constant i64 42
>> +; CHECK: .section      __TEXT,__literal8,8byte_literals
>> +; CHECK-NEXT: .align   3
>> +; CHECK-NEXT: L_private5:
>> +
>> + at private6 = private unnamed_addr constant i128 42
>> +; CHECK: .section      __TEXT,__literal16,16byte_literals
>> +; CHECK-NEXT: .align   3
>> +; CHECK-NEXT: L_private6:
>> +
>> +%struct._objc_class = type { i8* }
>> + at private7 = private global %struct._objc_class* null, section
>> "__OBJC,__cls_refs,literal_pointers,no_dead_strip"
>> +; CHECK: .section      __OBJC,__cls_refs,literal_pointers,no_dead_strip
>> +; CHECK: .align        3
>> +; CHECK: L_private7:
>> +
>> + at private8 = private global i32* null, section
>> "__DATA,__nl_symbol_ptr,non_lazy_symbol_pointers"
>> +; CHECK: .section      __DATA,__nl_symbol_ptr,non_lazy_symbol_pointers
>> +; CHECK-NEXT: .align   3
>> +; CHECK-NEXT: L_private8:
>> +
>> + at private9 = private global i32* null, section
>> "__DATA,__la_symbol_ptr,lazy_symbol_pointers"
>> +; CHECK: .section      __DATA,__la_symbol_ptr,lazy_symbol_pointers
>> +; CHECK-NEXT: .align   3
>> +; CHECK-NEXT: L_private9:
>> +
>> + at private10 = private global i32* null, section
>> "__DATA,__mod_init_func,mod_init_funcs"
>> +; CHECK: .section      __DATA,__mod_init_func,mod_init_funcs
>> +; CHECK-NEXT: .align   3
>> +; CHECK-NEXT: L_private10:
>> +
>> + at private11 = private global i32* null, section
>> "__DATA,__mod_term_func,mod_term_funcs"
>> +; CHECK: .section      __DATA,__mod_term_func,mod_term_funcs
>> +; CHECK-NEXT: .align   3
>> +; CHECK-NEXT: L_private11:
>> +
>> + at private12 = private global i32* null, section
>> "__DATA,__foobar,interposing"
>> +; CHECK: .section      __DATA,__foobar,interposing
>> +; CHECK-NEXT: .align   3
>> +; CHECK-NEXT: L_private12:
>>
>> Modified: llvm/trunk/test/CodeGen/X86/pr10420.ll
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/pr10420.ll?rev=201608&r1=201607&r2=201608&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/test/CodeGen/X86/pr10420.ll (original)
>> +++ llvm/trunk/test/CodeGen/X86/pr10420.ll Tue Feb 18 16:24:57 2014
>> @@ -14,7 +14,7 @@ define void @bar() {
>>         ret void;
>>  }
>>
>> -; CHECK: L_foo:                                   ## @foo
>> +; CHECK: l_foo:                                   ## @foo
>>  ; CHECK-NEXT: Ltmp0:
>>
>>  ; CHECK: _bar:                                   ## @bar
>> @@ -34,7 +34,7 @@ define void @bar() {
>>  ; CHECK-NEXT: {{.quad|.long}}   Ltmp[[NUM2]]
>>
>>
>> -; OLD: L_foo:                                   ## @foo
>> +; OLD: l_foo:                                   ## @foo
>>  ; OLD-NEXT: Ltmp0:
>>
>>  ; OLD: _bar:                                   ## @bar
>>
>> Modified: llvm/trunk/test/CodeGen/X86/private-2.ll
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/private-2.ll?rev=201608&r1=201607&r2=201608&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/test/CodeGen/X86/private-2.ll (original)
>> +++ llvm/trunk/test/CodeGen/X86/private-2.ll Tue Feb 18 16:24:57 2014
>> @@ -2,7 +2,7 @@
>>  ; Quote should be outside of private prefix.
>>  ; rdar://6855766x
>>
>> -; CHECK: L__ZZ20
>> +; CHECK: "l__ZZ20-[Example1 whatever]E4C.91"
>>
>>         %struct.A = type { i32*, i32 }
>>  @"_ZZ20-[Example1 whatever]E4C.91" = private constant %struct.A { i32*
>> null, i32 1 }           ; <%struct.A*> [#uses=1]
>>
>>
>> _______________________________________________
>> 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/20140219/f547d185/attachment.html>


More information about the llvm-commits mailing list