[llvm] r198438 - Make the llvm mangler depend only on DataLayout.

Saleem Abdulrasool compnerd at compnerd.org
Sun Jan 5 08:07:14 PST 2014


On Fri, Jan 3, 2014 at 11:21 AM, Rafael Espindola <
rafael.espindola at gmail.com> wrote:

> Author: rafael
> Date: Fri Jan  3 13:21:54 2014
> New Revision: 198438
>
> URL: http://llvm.org/viewvc/llvm-project?rev=198438&view=rev
> Log:
> Make the llvm mangler depend only on DataLayout.
>
> Before this patch any program that wanted to know the final symbol name of
> a
> GlobalValue had to link with Target.
>
> This patch implements a compromise solution where the mangler uses
> DataLayout.
> This way, any tool that already links with Target (llc, clang) gets the
> exact
> behavior as before and new IR files can be mangled without linking with
> Target.
>
> With this patch the mangler is constructed with just a DataLayout and
> DataLayout
> is extended to include the information the Mangler needs.
>
> Modified:
>     llvm/trunk/docs/LangRef.rst
>     llvm/trunk/include/llvm/IR/DataLayout.h
>     llvm/trunk/include/llvm/MC/MCAsmInfo.h
>     llvm/trunk/include/llvm/Target/Mangler.h
>     llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h
>     llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
>     llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
>     llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
>     llvm/trunk/lib/CodeGen/MachineFunction.cpp
>     llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp
>     llvm/trunk/lib/IR/DataLayout.cpp
>     llvm/trunk/lib/LTO/LTOCodeGenerator.cpp
>     llvm/trunk/lib/LTO/LTOModule.cpp
>     llvm/trunk/lib/MC/MCAsmInfo.cpp
>     llvm/trunk/lib/MC/MCAsmInfoCOFF.cpp
>     llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp
>     llvm/trunk/lib/Target/AArch64/AArch64TargetMachine.cpp
>     llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp
>     llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp
>     llvm/trunk/lib/Target/Hexagon/HexagonTargetMachine.cpp
>     llvm/trunk/lib/Target/MSP430/MSP430MCInstLower.cpp
>     llvm/trunk/lib/Target/MSP430/MSP430TargetMachine.cpp
>     llvm/trunk/lib/Target/Mangler.cpp
>     llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp
>     llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp
>     llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
>     llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp
>     llvm/trunk/lib/Target/PowerPC/PPCMCInstLower.cpp
>     llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp
>     llvm/trunk/lib/Target/Sparc/SparcAsmPrinter.cpp
>     llvm/trunk/lib/Target/Sparc/SparcTargetMachine.cpp
>     llvm/trunk/lib/Target/SystemZ/SystemZTargetMachine.cpp
>     llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp
>     llvm/trunk/lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp
>     llvm/trunk/lib/Target/X86/X86MCInstLower.cpp
>     llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
>     llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp
>     llvm/trunk/lib/Target/XCore/XCoreTargetMachine.cpp
>
> Modified: llvm/trunk/docs/LangRef.rst
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.rst?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/docs/LangRef.rst (original)
> +++ llvm/trunk/docs/LangRef.rst Fri Jan  3 13:21:54 2014
> @@ -1160,6 +1160,15 @@ as follows:
>  ``a<size>:<abi>:<pref>``
>      This specifies the alignment for an aggregate type of a given bit
>      ``<size>``.
> +``m:<mangling>``
> +   If prerest, specifies that llvm names are mangled in the output. The
> +   options are
> +   * ``e``: ELF mangling: Private symbols get a ``.L`` prefix.
> +   * ``m``: Mips mangling: Private symbols get a ``$`` prefix.
> +   * ``o``: Mach-O mangling: Private symbols get ``L`` prefix. Other
> +    symbols get a ``_`` prefix.
> +   * ``c``:  COFF prefix:  Similar to Mach-O, but stdcall and fastcall
> +  functions also get a sufiix based on the frame size.
>

Is this truly COFF or COFF/PE?  PE has diverged significantly from COFF,
and I think it would be nice to indicate that this is PE mangling (unless
Im mistaken and this is meant to be specifically COFF).  I may be mistaken
here, but I believe that the stdcall/fastcall mangling is PE specific.


>  ``n<size1>:<size2>:<size3>...``
>      This specifies a set of native integer widths for the target CPU in
>      bits. For example, it might contain ``n32`` for 32-bit PowerPC,
>
> Modified: llvm/trunk/include/llvm/IR/DataLayout.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DataLayout.h?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/IR/DataLayout.h (original)
> +++ llvm/trunk/include/llvm/IR/DataLayout.h Fri Jan  3 13:21:54 2014
> @@ -34,6 +34,7 @@ class Type;
>  class IntegerType;
>  class StructType;
>  class StructLayout;
> +class Triple;
>  class GlobalVariable;
>  class LLVMContext;
>  template<typename T>
> @@ -99,6 +100,15 @@ private:
>    bool          LittleEndian;          ///< Defaults to false
>    unsigned      StackNaturalAlign;     ///< Stack natural alignment
>
> +  enum ManglingModeT {
> +    MM_None,
> +    MM_ELF,
> +    MM_MachO,
> +    MM_COFF,
> +    MM_Mips
> +  };
> +  ManglingModeT ManglingMode;
> +
>    SmallVector<unsigned char, 8> LegalIntWidths; ///< Legal Integers.
>
>    /// Alignments - Where the primitive type alignment data is stored.
> @@ -174,6 +184,7 @@ public:
>      ImmutablePass(ID),
>      LittleEndian(DL.isLittleEndian()),
>      StackNaturalAlign(DL.StackNaturalAlign),
> +    ManglingMode(DL.ManglingMode),
>      LegalIntWidths(DL.LegalIntWidths),
>      Alignments(DL.Alignments),
>      Pointers(DL.Pointers),
> @@ -222,6 +233,48 @@ public:
>      return (StackNaturalAlign != 0) && (Align > StackNaturalAlign);
>    }
>
> +  bool hasMicrosoftFastStdCallMangling() const {
> +    return ManglingMode == MM_COFF;
> +  }
> +
> +  bool hasLinkerPrivateGlobalPrefix() const {
> +    return ManglingMode == MM_MachO;
> +  }
> +
> +  const char *getLinkerPrivateGlobalPrefix() const {
> +    if (ManglingMode == MM_MachO)
> +      return "l";
> +    return getPrivateGlobalPrefix();
> +  }
> +
> +  char getGlobalPrefix() const {
> +    switch (ManglingMode) {
> +    case MM_None:
> +    case MM_ELF:
> +    case MM_Mips:
> +      return '\0';
> +    case MM_MachO:
> +    case MM_COFF:
> +      return '_';
> +    }
> +  }
> +
> +  const char *getPrivateGlobalPrefix() const {
> +    switch (ManglingMode) {
> +    case MM_None:
> +      return "";
> +    case MM_ELF:
> +      return ".L";
> +    case MM_Mips:
> +      return "$";
> +    case MM_MachO:
> +    case MM_COFF:
> +      return "L";
> +    }
> +  }
> +
> +  static const char *getManglingComponent(const Triple &T);
> +
>    /// fitsInLegalInteger - This function returns true if the specified
> type fits
>    /// in a native integer type supported by the CPU.  For example, if the
> CPU
>    /// only supports i32 as a native integer type, then i27 fits in a legal
>
> Modified: llvm/trunk/include/llvm/MC/MCAsmInfo.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmInfo.h?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/MC/MCAsmInfo.h (original)
> +++ llvm/trunk/include/llvm/MC/MCAsmInfo.h Fri Jan  3 13:21:54 2014
> @@ -115,22 +115,11 @@ namespace llvm {
>      /// LabelSuffix - This is appended to emitted labels.
>      const char *DebugLabelSuffix;                 // Defaults to ":"
>
> -    /// If this is set to anything other than '\0', it is prepended
> -    /// onto all global symbols.  This is often used for '_'.
> -    char GlobalPrefix;                // Defaults to '\0'
> -
>      /// This prefix is used for globals like constant pool entries that
> are
>      /// completely private to the .s file and should not have names in
> the .o
>      /// file.
>      const char *PrivateGlobalPrefix;         // Defaults to "L"
>
> -    /// This prefix is used for symbols that should be passed through the
> -    /// assembler but be removed by the linker.  This is 'l' on Darwin,
> -    /// currently used for some ObjC metadata.
> -    /// The default of "" meast that for this system a plain private
> symbol
> -    /// should be used.
> -    const char *LinkerPrivateGlobalPrefix;    // Defaults to "".
> -
>      /// InlineAsmStart/End - If these are nonempty, they contain a
> directive to
>      /// emit before and after an inline assembly statement.
>      const char *InlineAsmStart;              // Defaults to "#APP\n"
> @@ -200,11 +189,6 @@ namespace llvm {
>      /// which doesn't support the '.bss' directive only.
>      bool UsesELFSectionDirectiveForBSS;      // Defaults to false.
>
> -    /// HasMicrosoftFastStdCallMangling - True if this target uses
> microsoft
> -    /// style mangling for functions with X86_StdCall/X86_FastCall calling
> -    /// convention.
> -    bool HasMicrosoftFastStdCallMangling;    // Defaults to false.
> -
>      bool NeedsDwarfSectionOffsetDirective;
>
>      //===--- Alignment Information
> ----------------------------------------===//
> @@ -393,10 +377,6 @@ namespace llvm {
>        return UsesELFSectionDirectiveForBSS;
>      }
>
> -    bool hasMicrosoftFastStdCallMangling() const {
> -      return HasMicrosoftFastStdCallMangling;
> -    }
> -
>      bool needsDwarfSectionOffsetDirective() const {
>        return NeedsDwarfSectionOffsetDirective;
>      }
> @@ -436,21 +416,9 @@ namespace llvm {
>      const char *getDebugLabelSuffix() const {
>        return DebugLabelSuffix;
>      }
> -
> -    char getGlobalPrefix() const {
> -      return GlobalPrefix;
> -    }
>      const char *getPrivateGlobalPrefix() const {
>        return PrivateGlobalPrefix;
>      }
> -    bool hasLinkerPrivateGlobalPrefix() const {
> -      return LinkerPrivateGlobalPrefix[0] != '\0';
> -    }
> -    const char *getLinkerPrivateGlobalPrefix() const {
> -      if (hasLinkerPrivateGlobalPrefix())
> -        return LinkerPrivateGlobalPrefix;
> -      return getPrivateGlobalPrefix();
> -    }
>      const char *getInlineAsmStart() const {
>        return InlineAsmStart;
>      }
>
> Modified: llvm/trunk/include/llvm/Target/Mangler.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/Mangler.h?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/Target/Mangler.h (original)
> +++ llvm/trunk/include/llvm/Target/Mangler.h Fri Jan  3 13:21:54 2014
> @@ -18,10 +18,10 @@
>
>  namespace llvm {
>
> +class DataLayout;
>  class GlobalValue;
>  class MCContext;
>  template <typename T> class SmallVectorImpl;
> -class TargetMachine;
>  class Twine;
>
>  class Mangler {
> @@ -33,7 +33,7 @@ public:
>    };
>
>  private:
> -  const TargetMachine *TM;
> +  const DataLayout *DL;
>
>    /// AnonGlobalIDs - We need to give global values the same name every
> time
>    /// they are mangled.  This keeps track of the number we give to
> anonymous
> @@ -46,7 +46,7 @@ private:
>    unsigned NextAnonGlobalID;
>
>  public:
> -  Mangler(const TargetMachine *TM) : TM(TM), NextAnonGlobalID(1) {}
> +  Mangler(const DataLayout *DL) : DL(DL), NextAnonGlobalID(1) {}
>
>    /// getNameWithPrefix - Fill OutName with the name of the appropriate
> prefix
>    /// and the specified global variable's name.  If the global variable
> doesn't
>
> Modified: llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h (original)
> +++ llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h Fri Jan  3
> 13:21:54 2014
> @@ -34,6 +34,7 @@ namespace llvm {
>
>  class TargetLoweringObjectFile : public MCObjectFileInfo {
>    MCContext *Ctx;
> +  const DataLayout *DL;
>
>    TargetLoweringObjectFile(
>      const TargetLoweringObjectFile&) LLVM_DELETED_FUNCTION;
> @@ -42,7 +43,7 @@ class TargetLoweringObjectFile : public
>  public:
>    MCContext &getContext() const { return *Ctx; }
>
> -  TargetLoweringObjectFile() : MCObjectFileInfo(), Ctx(0) {}
> +  TargetLoweringObjectFile() : MCObjectFileInfo(), Ctx(0), DL(0) {}
>
>    virtual ~TargetLoweringObjectFile();
>
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Fri Jan  3 13:21:54
> 2014
> @@ -165,7 +165,7 @@ bool AsmPrinter::doInitialization(Module
>
>    OutStreamer.InitStreamer();
>
> -  Mang = new Mangler(&TM);
> +  Mang = new Mangler(TM.getDataLayout());
>
>    // Allow the target to emit any magic that it wants at the start of the
> file.
>    EmitStartOfAsmFile(M);
> @@ -1106,6 +1106,7 @@ void AsmPrinter::EmitConstantPool() {
>  /// by the current function to the current output stream.
>  ///
>  void AsmPrinter::EmitJumpTableInfo() {
> +  const DataLayout *DL = MF->getTarget().getDataLayout();
>    const MachineJumpTableInfo *MJTI = MF->getJumpTableInfo();
>    if (MJTI == 0) return;
>    if (MJTI->getEntryKind() == MachineJumpTableInfo::EK_Inline) return;
> @@ -1171,7 +1172,7 @@ void AsmPrinter::EmitJumpTableInfo() {
>      // before each jump table.  The first label is never referenced, but
> tells
>      // the assembler and linker the extents of the jump table object.  The
>      // second label is actually referenced by the code.
> -    if (JTInDiffSection && MAI->hasLinkerPrivateGlobalPrefix())
> +    if (JTInDiffSection && DL->hasLinkerPrivateGlobalPrefix())
>        // FIXME: This doesn't have to have any specific name, just any
> randomly
>        // named and numbered 'l' label would work.  Simplify GetJTISymbol.
>        OutStreamer.EmitLabel(GetJTISymbol(JTI, true));
> @@ -1993,14 +1994,16 @@ void AsmPrinter::printOffset(int64_t Off
>  /// GetTempSymbol - Return the MCSymbol corresponding to the assembler
>  /// temporary label with the specified stem and unique ID.
>  MCSymbol *AsmPrinter::GetTempSymbol(StringRef Name, unsigned ID) const {
> -  return
> OutContext.GetOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix()) +
> +  const DataLayout *DL = TM.getDataLayout();
> +  return OutContext.GetOrCreateSymbol(Twine(DL->getPrivateGlobalPrefix())
> +
>                                        Name + Twine(ID));
>  }
>
>  /// GetTempSymbol - Return an assembler temporary label with the specified
>  /// stem.
>  MCSymbol *AsmPrinter::GetTempSymbol(StringRef Name) const {
> -  return
> OutContext.GetOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix())+
> +  const DataLayout *DL = TM.getDataLayout();
> +  return OutContext.GetOrCreateSymbol(Twine(DL->getPrivateGlobalPrefix())+
>                                        Name);
>  }
>
> @@ -2015,8 +2018,9 @@ MCSymbol *AsmPrinter::GetBlockAddressSym
>
>  /// GetCPISymbol - Return the symbol for the specified constant pool
> entry.
>  MCSymbol *AsmPrinter::GetCPISymbol(unsigned CPID) const {
> +  const DataLayout *DL = TM.getDataLayout();
>    return OutContext.GetOrCreateSymbol
> -    (Twine(MAI->getPrivateGlobalPrefix()) + "CPI" +
> Twine(getFunctionNumber())
> +    (Twine(DL->getPrivateGlobalPrefix()) + "CPI" +
> Twine(getFunctionNumber())
>       + "_" + Twine(CPID));
>  }
>
> @@ -2028,8 +2032,9 @@ MCSymbol *AsmPrinter::GetJTISymbol(unsig
>  /// GetJTSetSymbol - Return the symbol for the specified jump table .set
>  /// FIXME: privatize to AsmPrinter.
>  MCSymbol *AsmPrinter::GetJTSetSymbol(unsigned UID, unsigned MBBID) const {
> +  const DataLayout *DL = TM.getDataLayout();
>    return OutContext.GetOrCreateSymbol
> -  (Twine(MAI->getPrivateGlobalPrefix()) + Twine(getFunctionNumber()) +
> "_" +
> +  (Twine(DL->getPrivateGlobalPrefix()) + Twine(getFunctionNumber()) + "_"
> +
>     Twine(UID) + "_set_" + Twine(MBBID));
>  }
>
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp Fri Jan  3
> 13:21:54 2014
> @@ -19,6 +19,7 @@
>  #include "llvm/CodeGen/MachineBasicBlock.h"
>  #include "llvm/CodeGen/MachineModuleInfo.h"
>  #include "llvm/IR/Constants.h"
> +#include "llvm/IR/DataLayout.h"
>  #include "llvm/IR/InlineAsm.h"
>  #include "llvm/IR/LLVMContext.h"
>  #include "llvm/IR/Module.h"
> @@ -491,8 +492,9 @@ void AsmPrinter::EmitInlineAsm(const Mac
>  /// for their own strange codes.
>  void AsmPrinter::PrintSpecial(const MachineInstr *MI, raw_ostream &OS,
>                                const char *Code) const {
> +  const DataLayout *DL = TM.getDataLayout();
>    if (!strcmp(Code, "private")) {
> -    OS << MAI->getPrivateGlobalPrefix();
> +    OS << DL->getPrivateGlobalPrefix();
>    } else if (!strcmp(Code, "comment")) {
>      OS << MAI->getCommentString();
>    } else if (!strcmp(Code, "uid")) {
>
> Modified: llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp (original)
> +++ llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Fri Jan  3 13:21:54 2014
> @@ -52,7 +52,8 @@ MCSymbol *MachineBasicBlock::getSymbol()
>    if (!CachedMCSymbol) {
>      const MachineFunction *MF = getParent();
>      MCContext &Ctx = MF->getContext();
> -    const char *Prefix = Ctx.getAsmInfo()->getPrivateGlobalPrefix();
> +    const TargetMachine &TM = MF->getTarget();
> +    const char *Prefix = TM.getDataLayout()->getPrivateGlobalPrefix();
>      CachedMCSymbol = Ctx.GetOrCreateSymbol(Twine(Prefix) + "BB" +
>                                             Twine(MF->getFunctionNumber())
> +
>                                             "_" + Twine(getNumber()));
>
> Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original)
> +++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Fri Jan  3 13:21:54 2014
> @@ -447,12 +447,12 @@ unsigned MachineFunction::addLiveIn(unsi
>  /// normal 'L' label is returned.
>  MCSymbol *MachineFunction::getJTISymbol(unsigned JTI, MCContext &Ctx,
>                                          bool isLinkerPrivate) const {
> +  const DataLayout *DL = getTarget().getDataLayout();
>    assert(JumpTableInfo && "No jump tables");
>    assert(JTI < JumpTableInfo->getJumpTables().size() && "Invalid JTI!");
> -  const MCAsmInfo &MAI = *getTarget().getMCAsmInfo();
>
> -  const char *Prefix = isLinkerPrivate ?
> MAI.getLinkerPrivateGlobalPrefix() :
> -                                         MAI.getPrivateGlobalPrefix();
> +  const char *Prefix = isLinkerPrivate ?
> DL->getLinkerPrivateGlobalPrefix() :
> +                                         DL->getPrivateGlobalPrefix();
>    SmallString<60> Name;
>    raw_svector_ostream(Name)
>      << Prefix << "JTI" << getFunctionNumber() << '_' << JTI;
> @@ -462,8 +462,8 @@ MCSymbol *MachineFunction::getJTISymbol(
>  /// getPICBaseSymbol - Return a function-local symbol to represent the PIC
>  /// base.
>  MCSymbol *MachineFunction::getPICBaseSymbol() const {
> -  const MCAsmInfo &MAI = *Target.getMCAsmInfo();
> -  return Ctx.GetOrCreateSymbol(Twine(MAI.getPrivateGlobalPrefix())+
> +  const DataLayout *DL = getTarget().getDataLayout();
> +  return Ctx.GetOrCreateSymbol(Twine(DL->getPrivateGlobalPrefix())+
>                                 Twine(getFunctionNumber())+"$pb");
>  }
>
>
> Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp (original)
> +++ llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp Fri Jan  3 13:21:54 2014
> @@ -232,7 +232,7 @@ void *MCJIT::getPointerToBasicBlock(Basi
>  }
>
>  uint64_t MCJIT::getExistingSymbolAddress(const std::string &Name) {
> -  Mangler Mang(TM);
> +  Mangler Mang(TM->getDataLayout());
>    SmallString<128> FullName;
>    Mang.getNameWithPrefix(FullName, Name);
>    return Dyld.getSymbolLoadAddress(FullName);
> @@ -323,7 +323,7 @@ void *MCJIT::getPointerToFunction(Functi
>    //
>    // This is the accessor for the target address, so make sure to check
> the
>    // load address of the symbol, not the local address.
> -  Mangler Mang(TM);
> +  Mangler Mang(TM->getDataLayout());
>    SmallString<128> Name;
>    Mang.getNameWithPrefix(Name, F);
>    return (void*)Dyld.getSymbolLoadAddress(Name);
>
> Modified: llvm/trunk/lib/IR/DataLayout.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DataLayout.cpp?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/IR/DataLayout.cpp (original)
> +++ llvm/trunk/lib/IR/DataLayout.cpp Fri Jan  3 13:21:54 2014
> @@ -19,6 +19,7 @@
>  #include "llvm/IR/DataLayout.h"
>  #include "llvm/ADT/DenseMap.h"
>  #include "llvm/ADT/STLExtras.h"
> +#include "llvm/ADT/Triple.h"
>  #include "llvm/IR/Constants.h"
>  #include "llvm/IR/DerivedTypes.h"
>  #include "llvm/IR/Module.h"
> @@ -152,6 +153,15 @@ DataLayout::InvalidPointerElem = { 0U, 0
>  //                       DataLayout Class Implementation
>
>  //===----------------------------------------------------------------------===//
>
> +const char *DataLayout::getManglingComponent(const Triple &T) {
> +  if (T.isOSBinFormatMachO())
> +    return "-m:o";
> +  if (T.isOSBinFormatELF() || T.isArch64Bit())
> +    return "-m:e";
> +  assert(T.isOSBinFormatCOFF());
> +  return "-m:c";
> +}
> +
>  static const LayoutAlignElem DefaultAlignments[] = {
>    { INTEGER_ALIGN, 1, 1, 1 },    // i1
>    { INTEGER_ALIGN, 8, 1, 1 },    // i8
> @@ -173,6 +183,7 @@ void DataLayout::init(StringRef Desc) {
>    LayoutMap = 0;
>    LittleEndian = false;
>    StackNaturalAlign = 0;
> +  ManglingMode = MM_None;
>
>    // Default alignments
>    for (int I = 0, N = array_lengthof(DefaultAlignments); I < N; ++I) {
> @@ -305,6 +316,26 @@ void DataLayout::parseSpecifier(StringRe
>        StackNaturalAlign = inBytes(getInt(Tok));
>        break;
>      }
> +    case 'm':
> +      assert(Tok.empty());
> +      assert(Rest.size() == 1);
> +      switch(Rest[0]) {
> +      default:
> +        llvm_unreachable("Unknown mangling in datalayout string");
> +      case 'e':
> +        ManglingMode = MM_ELF;
> +        break;
> +      case 'o':
> +        ManglingMode = MM_MachO;
> +        break;
> +      case 'm':
> +        ManglingMode = MM_Mips;
> +        break;
> +      case 'c':
> +        ManglingMode = MM_COFF;
> +        break;
> +      }
> +      break;
>      default:
>        llvm_unreachable("Unknown specifier in datalayout string");
>        break;
> @@ -481,6 +512,24 @@ std::string DataLayout::getStringReprese
>    raw_string_ostream OS(Result);
>
>    OS << (LittleEndian ? "e" : "E");
> +
> +  switch (ManglingMode) {
> +  case MM_None:
> +    break;
> +  case MM_ELF:
> +    OS << "-m:e";
> +    break;
> +  case MM_MachO:
> +    OS << "-m:o";
> +    break;
> +  case MM_COFF:
> +    OS << "-m:c";
> +    break;
> +  case MM_Mips:
> +    OS << "-m:m";
> +    break;
> +  }
> +
>    SmallVector<unsigned, 8> addrSpaces;
>    // Lets get all of the known address spaces and sort them
>    // into increasing order so that we can emit the string
>
> Modified: llvm/trunk/lib/LTO/LTOCodeGenerator.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTOCodeGenerator.cpp?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/LTO/LTOCodeGenerator.cpp (original)
> +++ llvm/trunk/lib/LTO/LTOCodeGenerator.cpp Fri Jan  3 13:21:54 2014
> @@ -387,7 +387,7 @@ void LTOCodeGenerator::applyScopeRestric
>    passes.add(createVerifierPass());
>
>    // mark which symbols can not be internalized
> -  Mangler Mangler(TargetMach);
> +  Mangler Mangler(TargetMach->getDataLayout());
>    std::vector<const char*> MustPreserveList;
>    SmallPtrSet<GlobalValue*, 8> AsmUsed;
>    std::vector<StringRef> Libcalls;
>
> Modified: llvm/trunk/lib/LTO/LTOModule.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTOModule.cpp?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/LTO/LTOModule.cpp (original)
> +++ llvm/trunk/lib/LTO/LTOModule.cpp Fri Jan  3 13:21:54 2014
> @@ -44,7 +44,7 @@ using namespace llvm;
>  LTOModule::LTOModule(llvm::Module *m, llvm::TargetMachine *t)
>    : _module(m), _target(t),
>      _context(_target->getMCAsmInfo(), _target->getRegisterInfo(),
> &ObjFileInfo),
> -    _mangler(t) {
> +    _mangler(t->getDataLayout()) {
>    ObjFileInfo.InitMCObjectFileInfo(t->getTargetTriple(),
>                                     t->getRelocationModel(),
> t->getCodeModel(),
>                                     _context);
>
> Modified: llvm/trunk/lib/MC/MCAsmInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfo.cpp?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/MC/MCAsmInfo.cpp (original)
> +++ llvm/trunk/lib/MC/MCAsmInfo.cpp Fri Jan  3 13:21:54 2014
> @@ -41,9 +41,7 @@ MCAsmInfo::MCAsmInfo() {
>    CommentString = "#";
>    LabelSuffix = ":";
>    DebugLabelSuffix = ":";
> -  GlobalPrefix = '\0';
>    PrivateGlobalPrefix = "L";
> -  LinkerPrivateGlobalPrefix = "";
>    InlineAsmStart = "APP";
>    InlineAsmEnd = "NO_APP";
>    Code16Directive = ".code16";
> @@ -87,7 +85,6 @@ MCAsmInfo::MCAsmInfo() {
>    ExceptionsType = ExceptionHandling::None;
>    DwarfUsesRelocationsAcrossSections = true;
>    DwarfRegNumForCFI = false;
> -  HasMicrosoftFastStdCallMangling = false;
>    NeedsDwarfSectionOffsetDirective = false;
>    UseParensForSymbolVariant = false;
>  }
>
> Modified: llvm/trunk/lib/MC/MCAsmInfoCOFF.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfoCOFF.cpp?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/MC/MCAsmInfoCOFF.cpp (original)
> +++ llvm/trunk/lib/MC/MCAsmInfoCOFF.cpp Fri Jan  3 13:21:54 2014
> @@ -18,7 +18,6 @@ using namespace llvm;
>  void MCAsmInfoCOFF::anchor() { }
>
>  MCAsmInfoCOFF::MCAsmInfoCOFF() {
> -  GlobalPrefix = '_';
>    // MingW 4.5 and later support .comm with log2 alignment, but .lcomm
> uses byte
>    // alignment.
>    COMMDirectiveAlignmentIsInBytes = false;
> @@ -35,7 +34,6 @@ MCAsmInfoCOFF::MCAsmInfoCOFF() {
>    // Set up DWARF directives
>    HasLEB128 = true;  // Target asm supports leb128 directives
> (little-endian)
>    SupportsDebugInformation = true;
> -  HasMicrosoftFastStdCallMangling = true;
>    NeedsDwarfSectionOffsetDirective = true;
>  }
>
>
> Modified: llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp (original)
> +++ llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp Fri Jan  3 13:21:54 2014
> @@ -23,8 +23,6 @@ void MCAsmInfoDarwin::anchor() { }
>  MCAsmInfoDarwin::MCAsmInfoDarwin() {
>    // Common settings for all Darwin targets.
>    // Syntax:
> -  GlobalPrefix = '_';
> -  LinkerPrivateGlobalPrefix = "l";
>    HasSingleParameterDotFile = false;
>    HasSubsectionsViaSymbols = true;
>
>
> Modified: llvm/trunk/lib/Target/AArch64/AArch64TargetMachine.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64TargetMachine.cpp?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/AArch64/AArch64TargetMachine.cpp (original)
> +++ llvm/trunk/lib/Target/AArch64/AArch64TargetMachine.cpp Fri Jan  3
> 13:21:54 2014
> @@ -34,7 +34,7 @@ AArch64TargetMachine::AArch64TargetMachi
>    : LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
>      Subtarget(TT, CPU, FS),
>      InstrInfo(Subtarget),
> -    DL("e-i64:64-i128:128-n32:64-S128"),
> +    DL("e-m:e-i64:64-i128:128-n32:64-S128"),
>      TLInfo(*this),
>      TSInfo(*this),
>      FrameLowering(Subtarget) {
>
> Modified: llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp (original)
> +++ llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp Fri Jan  3 13:21:54 2014
> @@ -223,16 +223,18 @@ void ARMAsmPrinter::printOperand(const M
>
>  MCSymbol *ARMAsmPrinter::
>  GetARMJTIPICJumpTableLabel2(unsigned uid, unsigned uid2) const {
> +  const DataLayout *DL = TM.getDataLayout();
>    SmallString<60> Name;
> -  raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix() << "JTI"
> +  raw_svector_ostream(Name) << DL->getPrivateGlobalPrefix() << "JTI"
>      << getFunctionNumber() << '_' << uid << '_' << uid2;
>    return OutContext.GetOrCreateSymbol(Name.str());
>  }
>
>
>  MCSymbol *ARMAsmPrinter::GetARMSJLJEHLabel() const {
> +  const DataLayout *DL = TM.getDataLayout();
>    SmallString<60> Name;
> -  raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix() << "SJLJEH"
> +  raw_svector_ostream(Name) << DL->getPrivateGlobalPrefix() << "SJLJEH"
>      << getFunctionNumber();
>    return OutContext.GetOrCreateSymbol(Name.str());
>  }
> @@ -802,6 +804,7 @@ MCSymbol *ARMAsmPrinter::GetARMGVSymbol(
>
>  void ARMAsmPrinter::
>  EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) {
> +  const DataLayout *DL = TM.getDataLayout();
>    int Size = TM.getDataLayout()->getTypeAllocSize(MCPV->getType());
>
>    ARMConstantPoolValue *ACPV = static_cast<ARMConstantPoolValue*>(MCPV);
> @@ -810,7 +813,7 @@ EmitMachineConstantPoolValue(MachineCons
>    if (ACPV->isLSDA()) {
>      SmallString<128> Str;
>      raw_svector_ostream OS(Str);
> -    OS << MAI->getPrivateGlobalPrefix() << "_LSDA_" <<
> getFunctionNumber();
> +    OS << DL->getPrivateGlobalPrefix() << "_LSDA_" << getFunctionNumber();
>      MCSym = OutContext.GetOrCreateSymbol(OS.str());
>    } else if (ACPV->isBlockAddress()) {
>      const BlockAddress *BA =
> @@ -838,7 +841,7 @@ EmitMachineConstantPoolValue(MachineCons
>                              OutContext);
>
>    if (ACPV->getPCAdjustment()) {
> -    MCSymbol *PCLabel = getPICLabel(MAI->getPrivateGlobalPrefix(),
> +    MCSymbol *PCLabel = getPICLabel(DL->getPrivateGlobalPrefix(),
>                                      getFunctionNumber(),
>                                      ACPV->getLabelId(),
>                                      OutContext);
> @@ -1117,6 +1120,8 @@ extern cl::opt<bool> EnableARMEHABI;
>  #include "ARMGenMCPseudoLowering.inc"
>
>  void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
> +  const DataLayout *DL = TM.getDataLayout();
> +
>    // If we just ended a constant pool, mark it as such.
>    if (InConstantPool && MI->getOpcode() != ARM::CONSTPOOL_ENTRY) {
>      OutStreamer.EmitDataRegion(MCDR_DataRegionEnd);
> @@ -1254,7 +1259,7 @@ void ARMAsmPrinter::EmitInstruction(cons
>      MCSymbol *GVSym = GetARMGVSymbol(GV, TF);
>      const MCExpr *GVSymExpr = MCSymbolRefExpr::Create(GVSym, OutContext);
>
> -    MCSymbol *LabelSym = getPICLabel(MAI->getPrivateGlobalPrefix(),
> +    MCSymbol *LabelSym = getPICLabel(DL->getPrivateGlobalPrefix(),
>                                       getFunctionNumber(),
>                                       MI->getOperand(2).getImm(),
> OutContext);
>      const MCExpr *LabelSymExpr= MCSymbolRefExpr::Create(LabelSym,
> OutContext);
> @@ -1287,7 +1292,7 @@ void ARMAsmPrinter::EmitInstruction(cons
>      MCSymbol *GVSym = GetARMGVSymbol(GV, TF);
>      const MCExpr *GVSymExpr = MCSymbolRefExpr::Create(GVSym, OutContext);
>
> -    MCSymbol *LabelSym = getPICLabel(MAI->getPrivateGlobalPrefix(),
> +    MCSymbol *LabelSym = getPICLabel(DL->getPrivateGlobalPrefix(),
>                                       getFunctionNumber(),
>                                       MI->getOperand(3).getImm(),
> OutContext);
>      const MCExpr *LabelSymExpr= MCSymbolRefExpr::Create(LabelSym,
> OutContext);
> @@ -1313,7 +1318,7 @@ void ARMAsmPrinter::EmitInstruction(cons
>      // This adds the address of LPC0 to r0.
>
>      // Emit the label.
> -    OutStreamer.EmitLabel(getPICLabel(MAI->getPrivateGlobalPrefix(),
> +    OutStreamer.EmitLabel(getPICLabel(DL->getPrivateGlobalPrefix(),
>                            getFunctionNumber(), MI->getOperand(2).getImm(),
>                            OutContext));
>
> @@ -1334,7 +1339,7 @@ void ARMAsmPrinter::EmitInstruction(cons
>      // This adds the address of LPC0 to r0.
>
>      // Emit the label.
> -    OutStreamer.EmitLabel(getPICLabel(MAI->getPrivateGlobalPrefix(),
> +    OutStreamer.EmitLabel(getPICLabel(DL->getPrivateGlobalPrefix(),
>                            getFunctionNumber(), MI->getOperand(2).getImm(),
>                            OutContext));
>
> @@ -1365,7 +1370,7 @@ void ARMAsmPrinter::EmitInstruction(cons
>      // a PC-relative address at the ldr instruction.
>
>      // Emit the label.
> -    OutStreamer.EmitLabel(getPICLabel(MAI->getPrivateGlobalPrefix(),
> +    OutStreamer.EmitLabel(getPICLabel(DL->getPrivateGlobalPrefix(),
>                            getFunctionNumber(), MI->getOperand(2).getImm(),
>                            OutContext));
>
>
> Modified: llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp (original)
> +++ llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp Fri Jan  3 13:21:54 2014
> @@ -70,8 +70,13 @@ void ARMBaseTargetMachine::addAnalysisPa
>  void ARMTargetMachine::anchor() { }
>
>  static std::string computeDataLayout(ARMSubtarget &ST) {
> -  // Little endian. Pointers are 32 bits and aligned to 32 bits.
> -  std::string Ret = "e-p:32:32";
> +  // Little endian.
> +  std::string Ret = "e";
> +
> +  Ret += DataLayout::getManglingComponent(ST.getTargetTriple());
> +
> +  // Pointers are 32 bits and aligned to 32 bits.
> +  Ret += "-p:32:32";
>
>    // On thumb, i16,i18 and i1 have natural aligment requirements, but we
> try to
>    // align to 32.
>
> Modified: llvm/trunk/lib/Target/Hexagon/HexagonTargetMachine.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonTargetMachine.cpp?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/Hexagon/HexagonTargetMachine.cpp (original)
> +++ llvm/trunk/lib/Target/Hexagon/HexagonTargetMachine.cpp Fri Jan  3
> 13:21:54 2014
> @@ -71,7 +71,7 @@ HexagonTargetMachine::HexagonTargetMachi
>                                             CodeModel::Model CM,
>                                             CodeGenOpt::Level OL)
>    : LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
> -    DL("e-p:32:32-i1:32-i64:64-a:0-n32") ,
> +    DL("e-m:e-p:32:32-i1:32-i64:64-a:0-n32") ,
>      Subtarget(TT, CPU, FS), InstrInfo(Subtarget), TLInfo(*this),
>      TSInfo(*this),
>      FrameLowering(Subtarget),
>
> Modified: llvm/trunk/lib/Target/MSP430/MSP430MCInstLower.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430MCInstLower.cpp?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/MSP430/MSP430MCInstLower.cpp (original)
> +++ llvm/trunk/lib/Target/MSP430/MSP430MCInstLower.cpp Fri Jan  3 13:21:54
> 2014
> @@ -17,6 +17,7 @@
>  #include "llvm/CodeGen/AsmPrinter.h"
>  #include "llvm/CodeGen/MachineBasicBlock.h"
>  #include "llvm/CodeGen/MachineInstr.h"
> +#include "llvm/IR/DataLayout.h"
>  #include "llvm/MC/MCAsmInfo.h"
>  #include "llvm/MC/MCContext.h"
>  #include "llvm/MC/MCExpr.h"
> @@ -24,6 +25,7 @@
>  #include "llvm/Support/ErrorHandling.h"
>  #include "llvm/Support/raw_ostream.h"
>  #include "llvm/Target/Mangler.h"
> +#include "llvm/Target/TargetMachine.h"
>  using namespace llvm;
>
>  MCSymbol *MSP430MCInstLower::
> @@ -48,8 +50,9 @@ GetExternalSymbolSymbol(const MachineOpe
>
>  MCSymbol *MSP430MCInstLower::
>  GetJumpTableSymbol(const MachineOperand &MO) const {
> +  const DataLayout *DL = Printer.TM.getDataLayout();
>    SmallString<256> Name;
> -  raw_svector_ostream(Name) << Printer.MAI->getPrivateGlobalPrefix() <<
> "JTI"
> +  raw_svector_ostream(Name) << DL->getPrivateGlobalPrefix() << "JTI"
>                              << Printer.getFunctionNumber() << '_'
>                              << MO.getIndex();
>
> @@ -64,8 +67,9 @@ GetJumpTableSymbol(const MachineOperand
>
>  MCSymbol *MSP430MCInstLower::
>  GetConstantPoolIndexSymbol(const MachineOperand &MO) const {
> +  const DataLayout *DL = Printer.TM.getDataLayout();
>    SmallString<256> Name;
> -  raw_svector_ostream(Name) << Printer.MAI->getPrivateGlobalPrefix() <<
> "CPI"
> +  raw_svector_ostream(Name) << DL->getPrivateGlobalPrefix() << "CPI"
>                              << Printer.getFunctionNumber() << '_'
>                              << MO.getIndex();
>
>
> Modified: llvm/trunk/lib/Target/MSP430/MSP430TargetMachine.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430TargetMachine.cpp?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/MSP430/MSP430TargetMachine.cpp (original)
> +++ llvm/trunk/lib/Target/MSP430/MSP430TargetMachine.cpp Fri Jan  3
> 13:21:54 2014
> @@ -34,7 +34,7 @@ MSP430TargetMachine::MSP430TargetMachine
>    : LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
>      Subtarget(TT, CPU, FS),
>      // FIXME: Check DataLayout string.
> -    DL("e-p:16:16-i32:16:32-n8:16"),
> +    DL("e-m:e-p:16:16-i32:16:32-n8:16"),
>      InstrInfo(*this), TLInfo(*this), TSInfo(*this),
>      FrameLowering(Subtarget) {
>    initAsmInfo();
>
> Modified: llvm/trunk/lib/Target/Mangler.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mangler.cpp?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/Mangler.cpp (original)
> +++ llvm/trunk/lib/Target/Mangler.cpp Fri Jan  3 13:21:54 2014
> @@ -17,9 +17,7 @@
>  #include "llvm/IR/DataLayout.h"
>  #include "llvm/IR/DerivedTypes.h"
>  #include "llvm/IR/Function.h"
> -#include "llvm/MC/MCAsmInfo.h"
>  #include "llvm/MC/MCContext.h"
> -#include "llvm/Target/TargetMachine.h"
>  #include "llvm/Support/raw_ostream.h"
>  using namespace llvm;
>
> @@ -31,23 +29,20 @@ void Mangler::getNameWithPrefix(SmallVec
>    SmallString<256> TmpData;
>    StringRef Name = GVName.toStringRef(TmpData);
>    assert(!Name.empty() && "getNameWithPrefix requires non-empty name");
> -
> -  const MCAsmInfo *MAI = TM->getMCAsmInfo();
> -
> +
>    // If the global name is not led with \1, add the appropriate prefixes.
>    if (Name[0] == '\1') {
>      Name = Name.substr(1);
>    } else {
>      if (PrefixTy == Mangler::Private) {
> -      const char *Prefix = MAI->getPrivateGlobalPrefix();
> +      const char *Prefix = DL->getPrivateGlobalPrefix();
>        OutName.append(Prefix, Prefix+strlen(Prefix));
>      } else if (PrefixTy == Mangler::LinkerPrivate) {
> -      const char *Prefix = MAI->getLinkerPrivateGlobalPrefix();
> +      const char *Prefix = DL->getLinkerPrivateGlobalPrefix();
>        OutName.append(Prefix, Prefix+strlen(Prefix));
>      }
>
> -
> -    char Prefix = MAI->getGlobalPrefix();
> +    char Prefix = DL->getGlobalPrefix();
>      if (Prefix != '\0')
>        OutName.push_back(Prefix);
>    }
> @@ -105,10 +100,10 @@ void Mangler::getNameWithPrefix(SmallVec
>      // Must mangle the global into a unique ID.
>      getNameWithPrefix(OutName, "__unnamed_" + Twine(ID), PrefixTy);
>    }
> -
> +
>    // If we are supposed to add a microsoft-style suffix for
> stdcall/fastcall,
>    // add it.
> -  if (TM->getMCAsmInfo()->hasMicrosoftFastStdCallMangling()) {
> +  if (DL->hasMicrosoftFastStdCallMangling()) {
>      if (const Function *F = dyn_cast<Function>(GV)) {
>        CallingConv::ID CC = F->getCallingConv();
>
> @@ -128,7 +123,7 @@ void Mangler::getNameWithPrefix(SmallVec
>            // "Pure" variadic functions do not receive @0 suffix.
>            (!FT->isVarArg() || FT->getNumParams() == 0 ||
>             (FT->getNumParams() == 1 && F->hasStructRetAttr())))
> -        AddFastCallStdCallSuffix(OutName, F, *TM->getDataLayout());
> +        AddFastCallStdCallSuffix(OutName, F, *DL);
>      }
>    }
>  }
>
> Modified: llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp (original)
> +++ llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp Fri Jan  3 13:21:54 2014
> @@ -495,6 +495,7 @@ bool MipsAsmPrinter::PrintAsmMemoryOpera
>
>  void MipsAsmPrinter::printOperand(const MachineInstr *MI, int opNum,
>                                    raw_ostream &O) {
> +  const DataLayout *DL = TM.getDataLayout();
>    const MachineOperand &MO = MI->getOperand(opNum);
>    bool closeP = false;
>
> @@ -543,7 +544,7 @@ void MipsAsmPrinter::printOperand(const
>      }
>
>      case MachineOperand::MO_ConstantPoolIndex:
> -      O << MAI->getPrivateGlobalPrefix() << "CPI"
> +      O << DL->getPrivateGlobalPrefix() << "CPI"
>          << getFunctionNumber() << "_" << MO.getIndex();
>        if (MO.getOffset())
>          O << "+" << MO.getOffset();
>
> Modified: llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp (original)
> +++ llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp Fri Jan  3 13:21:54
> 2014
> @@ -54,6 +54,8 @@ static std::string computeDataLayout(con
>    else
>      Ret += "E";
>
> +  Ret += "-m:m";
> +
>    // Pointers are 32 bit on some ABIs.
>    if (!ST.isABI_N64())
>      Ret += "-p:32:32";
>
> Modified: llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp (original)
> +++ llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp Fri Jan  3 13:21:54
> 2014
> @@ -895,7 +895,7 @@ bool NVPTXAsmPrinter::doInitialization(M
>    const_cast<TargetLoweringObjectFile &>(getObjFileLowering())
>        .Initialize(OutContext, TM);
>
> -  Mang = new Mangler(&TM);
> +  Mang = new Mangler(TM.getDataLayout());
>
>    // Emit header before any dwarf directives are emitted below.
>    emitHeader(M, OS1);
>
> Modified: llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp (original)
> +++ llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp Fri Jan  3 13:21:54
> 2014
> @@ -139,6 +139,7 @@ static const char *stripRegisterPrefix(c
>
>  void PPCAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
>                                   raw_ostream &O) {
> +  const DataLayout *DL = TM.getDataLayout();
>    const MachineOperand &MO = MI->getOperand(OpNo);
>
>    switch (MO.getType()) {
> @@ -158,7 +159,7 @@ void PPCAsmPrinter::printOperand(const M
>      O << *MO.getMBB()->getSymbol();
>      return;
>    case MachineOperand::MO_ConstantPoolIndex:
> -    O << MAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
> +    O << DL->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
>        << '_' << MO.getIndex();
>      return;
>    case MachineOperand::MO_BlockAddress:
> @@ -281,12 +282,12 @@ bool PPCAsmPrinter::PrintAsmMemoryOperan
>  /// exists for it.  If not, create one.  Then return a symbol that
> references
>  /// the TOC entry.
>  MCSymbol *PPCAsmPrinter::lookUpOrCreateTOCEntry(MCSymbol *Sym) {
> -
> +  const DataLayout *DL = TM.getDataLayout();
>    MCSymbol *&TOCEntry = TOC[Sym];
>
>    // To avoid name clash check if the name already exists.
>    while (TOCEntry == 0) {
> -    if (OutContext.LookupSymbol(Twine(MAI->getPrivateGlobalPrefix()) +
> +    if (OutContext.LookupSymbol(Twine(DL->getPrivateGlobalPrefix()) +
>                                  "C" + Twine(TOCLabelID++)) == 0) {
>        TOCEntry = GetTempSymbol("C", TOCLabelID);
>      }
>
> Modified: llvm/trunk/lib/Target/PowerPC/PPCMCInstLower.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCMCInstLower.cpp?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/PowerPC/PPCMCInstLower.cpp (original)
> +++ llvm/trunk/lib/Target/PowerPC/PPCMCInstLower.cpp Fri Jan  3 13:21:54
> 2014
> @@ -19,11 +19,13 @@
>  #include "llvm/CodeGen/AsmPrinter.h"
>  #include "llvm/CodeGen/MachineFunction.h"
>  #include "llvm/CodeGen/MachineModuleInfoImpls.h"
> +#include "llvm/IR/DataLayout.h"
>  #include "llvm/IR/GlobalValue.h"
>  #include "llvm/MC/MCAsmInfo.h"
>  #include "llvm/MC/MCExpr.h"
>  #include "llvm/MC/MCInst.h"
>  #include "llvm/Target/Mangler.h"
> +#include "llvm/Target/TargetMachine.h"
>  using namespace llvm;
>
>  static MachineModuleInfoMachO &getMachOMMI(AsmPrinter &AP) {
> @@ -32,6 +34,7 @@ static MachineModuleInfoMachO &getMachOM
>
>
>  static MCSymbol *GetSymbolFromOperand(const MachineOperand &MO,
> AsmPrinter &AP){
> +  const DataLayout *DL = AP.TM.getDataLayout();
>    MCContext &Ctx = AP.OutContext;
>
>    SmallString<128> Name;
> @@ -42,7 +45,7 @@ static MCSymbol *GetSymbolFromOperand(co
>      Suffix = "$non_lazy_ptr";
>
>    if (!Suffix.empty())
> -    Name += AP.MAI->getPrivateGlobalPrefix();
> +    Name += DL->getPrivateGlobalPrefix();
>
>    unsigned PrefixLen = Name.size();
>
>
> Modified: llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp (original)
> +++ llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp Fri Jan  3 13:21:54
> 2014
> @@ -40,6 +40,8 @@ static std::string getDataLayoutString(c
>    // PPC is big endian.
>    std::string Ret = "E";
>
> +  Ret += DataLayout::getManglingComponent(T);
> +
>    // PPC32 has 32 bit pointers. The PS3 (OS Lv2) is a PPC64 machine with
> 32 bit
>    // pointers.
>    if (!ST.isPPC64() || T.getOS() == Triple::Lv2)
>
> Modified: llvm/trunk/lib/Target/Sparc/SparcAsmPrinter.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/SparcAsmPrinter.cpp?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/Sparc/SparcAsmPrinter.cpp (original)
> +++ llvm/trunk/lib/Target/Sparc/SparcAsmPrinter.cpp Fri Jan  3 13:21:54
> 2014
> @@ -219,6 +219,7 @@ void SparcAsmPrinter::EmitFunctionBodySt
>
>  void SparcAsmPrinter::printOperand(const MachineInstr *MI, int opNum,
>                                     raw_ostream &O) {
> +  const DataLayout *DL = TM.getDataLayout();
>    const MachineOperand &MO = MI->getOperand (opNum);
>    unsigned TF = MO.getTargetFlags();
>  #ifndef NDEBUG
> @@ -318,7 +319,7 @@ void SparcAsmPrinter::printOperand(const
>      O << MO.getSymbolName();
>      break;
>    case MachineOperand::MO_ConstantPoolIndex:
> -    O << MAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() <<
> "_"
> +    O << DL->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() <<
> "_"
>        << MO.getIndex();
>      break;
>    default:
>
> Modified: llvm/trunk/lib/Target/Sparc/SparcTargetMachine.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/SparcTargetMachine.cpp?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/Sparc/SparcTargetMachine.cpp (original)
> +++ llvm/trunk/lib/Target/Sparc/SparcTargetMachine.cpp Fri Jan  3 13:21:54
> 2014
> @@ -25,7 +25,7 @@ extern "C" void LLVMInitializeSparcTarge
>
>  static std::string computeDataLayout(const SparcSubtarget &ST) {
>    // Sparc is big endian.
> -  std::string Ret = "E";
> +  std::string Ret = "E-m:e";
>
>    // Some ABIs have 32bit pointers.
>    if (!ST.is64Bit())
>
> Modified: llvm/trunk/lib/Target/SystemZ/SystemZTargetMachine.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZTargetMachine.cpp?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/SystemZ/SystemZTargetMachine.cpp (original)
> +++ llvm/trunk/lib/Target/SystemZ/SystemZTargetMachine.cpp Fri Jan  3
> 13:21:54 2014
> @@ -30,7 +30,7 @@ SystemZTargetMachine::SystemZTargetMachi
>      // Make sure that global data has at least 16 bits of alignment by
> default,
>      // so that we can refer to it using LARL.  We don't have any special
>      // requirements for stack variables though.
> -    DL("E-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64"),
> +    DL("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64"),
>      InstrInfo(*this), TLInfo(*this), TSInfo(*this),
>      FrameLowering(*this, Subtarget) {
>    initAsmInfo();
>
> Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original)
> +++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Fri Jan  3 13:21:54
> 2014
> @@ -41,6 +41,7 @@ using namespace llvm;
>  void TargetLoweringObjectFile::Initialize(MCContext &ctx,
>                                            const TargetMachine &TM) {
>    Ctx = &ctx;
> +  DL = TM.getDataLayout();
>    InitMCObjectFileInfo(TM.getTargetTriple(),
>                         TM.getRelocationModel(), TM.getCodeModel(), *Ctx);
>  }
> @@ -114,9 +115,8 @@ MCSymbol *TargetLoweringObjectFile::getS
>    assert(!GV->hasLinkerPrivateLinkage());
>    assert(!GV->hasLinkerPrivateWeakLinkage());
>
> -  const MCAsmInfo *MAI = Ctx->getAsmInfo();
>    SmallString<60> NameStr;
> -  NameStr += MAI->getPrivateGlobalPrefix();
> +  NameStr += DL->getPrivateGlobalPrefix();
>    M.getNameWithPrefix(NameStr, GV);
>    NameStr.append(Suffix.begin(), Suffix.end());
>    return Ctx->GetOrCreateSymbol(NameStr.str());
>
> Modified: llvm/trunk/lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp (original)
> +++ llvm/trunk/lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp Fri Jan  3
> 13:21:54 2014
> @@ -131,11 +131,8 @@ getNonexecutableStackSection(MCContext &
>  void X86MCAsmInfoMicrosoft::anchor() { }
>
>  X86MCAsmInfoMicrosoft::X86MCAsmInfoMicrosoft(const Triple &Triple) {
> -  if (Triple.getArch() == Triple::x86_64) {
> -    GlobalPrefix = '\0';
> +  if (Triple.getArch() == Triple::x86_64)
>      PrivateGlobalPrefix = ".L";
> -    HasMicrosoftFastStdCallMangling = false;
> -  }
>
>    AssemblerDialect = AsmWriterFlavor;
>
> @@ -147,11 +144,8 @@ X86MCAsmInfoMicrosoft::X86MCAsmInfoMicro
>  void X86MCAsmInfoGNUCOFF::anchor() { }
>
>  X86MCAsmInfoGNUCOFF::X86MCAsmInfoGNUCOFF(const Triple &Triple) {
> -  if (Triple.getArch() == Triple::x86_64) {
> -    GlobalPrefix = '\0';
> +  if (Triple.getArch() == Triple::x86_64)
>      PrivateGlobalPrefix = ".L";
> -    HasMicrosoftFastStdCallMangling = false;
> -  }
>
>    AssemblerDialect = AsmWriterFlavor;
>
>
> Modified: llvm/trunk/lib/Target/X86/X86MCInstLower.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86MCInstLower.cpp?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/X86/X86MCInstLower.cpp (original)
> +++ llvm/trunk/lib/Target/X86/X86MCInstLower.cpp Fri Jan  3 13:21:54 2014
> @@ -70,6 +70,7 @@ MachineModuleInfoMachO &X86MCInstLower::
>  /// operand to an MCSymbol.
>  MCSymbol *X86MCInstLower::
>  GetSymbolFromOperand(const MachineOperand &MO) const {
> +  const DataLayout *DL = TM.getDataLayout();
>    assert((MO.isGlobal() || MO.isSymbol() || MO.isMBB()) && "Isn't a
> symbol reference");
>
>    SmallString<128> Name;
> @@ -91,7 +92,7 @@ GetSymbolFromOperand(const MachineOperan
>    }
>
>    if (!Suffix.empty())
> -    Name += MAI.getPrivateGlobalPrefix();
> +    Name += DL->getPrivateGlobalPrefix();
>
>    unsigned PrefixLen = Name.size();
>
>
> Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.cpp?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp (original)
> +++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Fri Jan  3 13:21:54 2014
> @@ -34,6 +34,7 @@ static std::string computeDataLayout(con
>    // X86 is little endian
>    std::string Ret = "e";
>
> +  Ret += DataLayout::getManglingComponent(ST.getTargetTriple());
>    // X86 and x32 have 32 bit pointers.
>    if (ST.isTarget64BitILP32() || !ST.is64Bit())
>      Ret += "-p:32:32";
>
> Modified: llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp (original)
> +++ llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp Fri Jan  3 13:21:54
> 2014
> @@ -204,6 +204,7 @@ printInlineJT(const MachineInstr *MI, in
>
>  void XCoreAsmPrinter::printOperand(const MachineInstr *MI, int opNum,
>                                     raw_ostream &O) {
> +  const DataLayout *DL = TM.getDataLayout();
>    const MachineOperand &MO = MI->getOperand(opNum);
>    switch (MO.getType()) {
>    case MachineOperand::MO_Register:
> @@ -219,7 +220,7 @@ void XCoreAsmPrinter::printOperand(const
>      O << *getSymbol(MO.getGlobal());
>      break;
>    case MachineOperand::MO_ConstantPoolIndex:
> -    O << MAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
> +    O << DL->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
>        << '_' << MO.getIndex();
>      break;
>    case MachineOperand::MO_BlockAddress:
>
> Modified: llvm/trunk/lib/Target/XCore/XCoreTargetMachine.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreTargetMachine.cpp?rev=198438&r1=198437&r2=198438&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/XCore/XCoreTargetMachine.cpp (original)
> +++ llvm/trunk/lib/Target/XCore/XCoreTargetMachine.cpp Fri Jan  3 13:21:54
> 2014
> @@ -27,7 +27,7 @@ XCoreTargetMachine::XCoreTargetMachine(c
>                                         CodeGenOpt::Level OL)
>    : LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
>      Subtarget(TT, CPU, FS),
> -    DL("e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i64:32-f64:32-a:0:32-n32"),
> +
>  DL("e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i64:32-f64:32-a:0:32-n32"),
>      InstrInfo(),
>      FrameLowering(Subtarget),
>      TLInfo(*this),
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>



-- 
Saleem Abdulrasool
compnerd (at) compnerd (dot) org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140105/71652ef6/attachment.html>


More information about the llvm-commits mailing list