Index: include/clang/Basic/TargetInfo.h =================================================================== --- include/clang/Basic/TargetInfo.h +++ include/clang/Basic/TargetInfo.h @@ -21,13 +21,14 @@ #include "clang/Basic/TargetCXXABI.h" #include "clang/Basic/TargetOptions.h" #include "clang/Basic/VersionTuple.h" -#include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/APInt.h" +#include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/Triple.h" +#include "llvm/IR/DataLayout.h" #include "llvm/Support/DataTypes.h" #include #include @@ -74,8 +75,7 @@ unsigned short MaxVectorAlign; unsigned short MaxTLSAlign; unsigned short SimdDefaultAlign; - const char *DataLayoutString; - const char *UserLabelPrefix; + std::unique_ptr DataLayout; const char *MCountName; const llvm::fltSemantics *HalfFormat, *FloatFormat, *DoubleFormat, *LongDoubleFormat; @@ -95,6 +95,10 @@ // TargetInfo Constructor. Default initializes all fields. TargetInfo(const llvm::Triple &T); + void resetDataLayout(StringRef DL) { + DataLayout.reset(new llvm::DataLayout(DL)); + } + public: /// \brief Construct a target for the given options. /// @@ -426,14 +430,6 @@ return PointerWidth; } - /// \brief Returns the default value of the __USER_LABEL_PREFIX__ macro, - /// which is the prefix given to user symbols by default. - /// - /// On most platforms this is "_", but it is "" on some, and "." on others. - const char *getUserLabelPrefix() const { - return UserLabelPrefix; - } - /// \brief Returns the name of the mcount instrumentation function. const char *getMCountName() const { return MCountName; @@ -721,9 +717,9 @@ return Triple; } - const char *getDataLayoutString() const { - assert(DataLayoutString && "Uninitialized DataLayoutString!"); - return DataLayoutString; + const llvm::DataLayout &getDataLayout() const { + assert(DataLayout && "Uninitialized DataLayout!"); + return *DataLayout; } struct GCCRegAlias { Index: include/clang/CodeGen/BackendUtil.h =================================================================== --- include/clang/CodeGen/BackendUtil.h +++ include/clang/CodeGen/BackendUtil.h @@ -35,8 +35,8 @@ void EmitBackendOutput(DiagnosticsEngine &Diags, const CodeGenOptions &CGOpts, const TargetOptions &TOpts, const LangOptions &LOpts, - StringRef TDesc, llvm::Module *M, BackendAction Action, - raw_pwrite_stream *OS); + llvm::DataLayout TDesc, llvm::Module *M, + BackendAction Action, raw_pwrite_stream *OS); } #endif Index: lib/AST/Mangle.cpp =================================================================== --- lib/AST/Mangle.cpp +++ lib/AST/Mangle.cpp @@ -126,9 +126,9 @@ // llvm mangler on ELF is a nop, so we can just avoid adding the \01 // marker. We also avoid adding the marker if this is an alias for an // LLVM intrinsic. - StringRef UserLabelPrefix = - getASTContext().getTargetInfo().getUserLabelPrefix(); - if (!UserLabelPrefix.empty() && !ALA->getLabel().startswith("llvm.")) + char GlobalPrefix = + getASTContext().getTargetInfo().getDataLayout().getGlobalPrefix(); + if (GlobalPrefix && !ALA->getLabel().startswith("llvm.")) Out << '\01'; // LLVM IR Marker for __asm("foo") Out << ALA->getLabel(); Index: lib/Basic/TargetInfo.cpp =================================================================== --- lib/Basic/TargetInfo.cpp +++ lib/Basic/TargetInfo.cpp @@ -72,8 +72,6 @@ FloatFormat = &llvm::APFloat::IEEEsingle; DoubleFormat = &llvm::APFloat::IEEEdouble; LongDoubleFormat = &llvm::APFloat::IEEEdouble; - DataLayoutString = nullptr; - UserLabelPrefix = "_"; MCountName = "mcount"; RegParmMax = 0; SSERegParmMax = 0; Index: lib/Basic/Targets.cpp =================================================================== --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -102,9 +102,7 @@ public: CloudABITargetInfo(const llvm::Triple &Triple) - : OSTargetInfo(Triple) { - this->UserLabelPrefix = ""; - } + : OSTargetInfo(Triple) {} }; static void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts, @@ -284,8 +282,6 @@ public: DragonFlyBSDTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) { - this->UserLabelPrefix = ""; - switch (Triple.getArch()) { default: case llvm::Triple::x86: @@ -327,8 +323,6 @@ } public: FreeBSDTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) { - this->UserLabelPrefix = ""; - switch (Triple.getArch()) { default: case llvm::Triple::x86: @@ -368,9 +362,7 @@ } public: KFreeBSDTargetInfo(const llvm::Triple &Triple) - : OSTargetInfo(Triple) { - this->UserLabelPrefix = ""; - } + : OSTargetInfo(Triple) {} }; // Minix Target @@ -392,9 +384,7 @@ DefineStd(Builder, "unix", Opts); } public: - MinixTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) { - this->UserLabelPrefix = ""; - } + MinixTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {} }; // Linux target @@ -422,7 +412,6 @@ } public: LinuxTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) { - this->UserLabelPrefix = ""; this->WIntType = TargetInfo::UnsignedInt; switch (Triple.getArch()) { @@ -467,7 +456,6 @@ } public: NetBSDTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) { - this->UserLabelPrefix = ""; this->MCountName = "_mcount"; } }; @@ -488,7 +476,6 @@ } public: OpenBSDTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) { - this->UserLabelPrefix = ""; this->TLSSupported = false; switch (Triple.getArch()) { @@ -536,7 +523,6 @@ } public: BitrigTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) { - this->UserLabelPrefix = ""; this->MCountName = "__mcount"; } }; @@ -554,9 +540,7 @@ Builder.defineMacro("__ELF__"); } public: - PSPTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) { - this->UserLabelPrefix = ""; - } + PSPTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {} }; // PS3 PPU Target @@ -576,13 +560,12 @@ } public: PS3PPUTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) { - this->UserLabelPrefix = ""; this->LongWidth = this->LongAlign = 32; this->PointerWidth = this->PointerAlign = 32; this->IntMaxType = TargetInfo::SignedLongLong; this->Int64Type = TargetInfo::SignedLongLong; this->SizeType = TargetInfo::UnsignedInt; - this->DataLayoutString = "E-m:e-p:32:32-i64:64-n32:64"; + this->resetDataLayout("E-m:e-p:32:32-i64:64-n32:64"); } }; @@ -604,7 +587,6 @@ // On PS4, TLS variable cannot be aligned to more than 32 bytes (256 bits). this->MaxTLSAlign = 256; - this->UserLabelPrefix = ""; // On PS4, do not honor explicit bit field alignment, // as in "__attribute__((aligned(2))) int b : 1;". @@ -647,7 +629,6 @@ } public: SolarisTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) { - this->UserLabelPrefix = ""; this->WCharType = this->SignedInt; // FIXME: WIntType should be SignedLong } @@ -728,7 +709,6 @@ public: NaClTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) { - this->UserLabelPrefix = ""; this->LongAlign = 32; this->LongWidth = 32; this->PointerAlign = 32; @@ -748,14 +728,14 @@ if (Triple.getArch() == llvm::Triple::arm) { // Handled in ARM's setABI(). } else if (Triple.getArch() == llvm::Triple::x86) { - this->DataLayoutString = "e-m:e-p:32:32-i64:64-n8:16:32-S128"; + this->resetDataLayout("e-m:e-p:32:32-i64:64-n8:16:32-S128"); } else if (Triple.getArch() == llvm::Triple::x86_64) { - this->DataLayoutString = "e-m:e-p:32:32-i64:64-n8:16:32:64-S128"; + this->resetDataLayout("e-m:e-p:32:32-i64:64-n8:16:32:64-S128"); } else if (Triple.getArch() == llvm::Triple::mipsel) { - // Handled on mips' setDataLayoutString. + // Handled on mips' setDataLayout. } else { assert(Triple.getArch() == llvm::Triple::le32); - this->DataLayoutString = "e-p:32:32-i64:64"; + this->resetDataLayout("e-p:32:32-i64:64"); } } }; @@ -782,7 +762,6 @@ explicit WebAssemblyOSTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) { this->MCountName = "__mcount"; - this->UserLabelPrefix = ""; this->TheCXXABI.set(TargetCXXABI::WebAssembly); } }; @@ -1495,7 +1474,7 @@ class PPC32TargetInfo : public PPCTargetInfo { public: PPC32TargetInfo(const llvm::Triple &Triple) : PPCTargetInfo(Triple) { - DataLayoutString = "E-m:e-p:32:32-i64:64-n32"; + resetDataLayout("E-m:e-p:32:32-i64:64-n32"); switch (getTriple().getOS()) { case llvm::Triple::Linux: @@ -1534,10 +1513,10 @@ Int64Type = SignedLong; if ((Triple.getArch() == llvm::Triple::ppc64le)) { - DataLayoutString = "e-m:e-i64:64-n32:64"; + resetDataLayout("e-m:e-i64:64-n32:64"); ABI = "elfv2"; } else { - DataLayoutString = "E-m:e-i64:64-n32:64"; + resetDataLayout("E-m:e-i64:64-n32:64"); ABI = "elfv1"; } @@ -1580,7 +1559,7 @@ PtrDiffType = SignedInt; // for http://llvm.org/bugs/show_bug.cgi?id=15726 LongLongAlign = 32; SuitableAlign = 128; - DataLayoutString = "E-m:o-p:32:32-f64:32:64-n32"; + resetDataLayout("E-m:o-p:32:32-f64:32:64-n32"); } BuiltinVaListKind getBuiltinVaListKind() const override { return TargetInfo::CharPtrBuiltinVaList; @@ -1594,7 +1573,7 @@ : DarwinTargetInfo(Triple) { HasAlignMac68kSupport = true; SuitableAlign = 128; - DataLayoutString = "E-m:o-i64:64-n32:64"; + resetDataLayout("E-m:o-i64:64-n32:64"); } }; @@ -1736,7 +1715,7 @@ SizeType = TargetInfo::UnsignedInt; PtrDiffType = TargetInfo::SignedInt; IntPtrType = TargetInfo::SignedInt; - DataLayoutString = "e-p:32:32-i64:64-v16:16-v32:32-n16:32:64"; + resetDataLayout("e-p:32:32-i64:64-v16:16-v32:32-n16:32:64"); } }; @@ -1747,7 +1726,7 @@ SizeType = TargetInfo::UnsignedLong; PtrDiffType = TargetInfo::SignedLong; IntPtrType = TargetInfo::SignedLong; - DataLayoutString = "e-i64:64-v16:16-v32:32-n16:32:64"; + resetDataLayout("e-i64:64-v16:16-v32:32-n16:32:64"); } }; @@ -1806,13 +1785,13 @@ : TargetInfo(Triple) { if (Triple.getArch() == llvm::Triple::amdgcn) { - DataLayoutString = DataLayoutStringSI; + resetDataLayout(DataLayoutStringSI); GPU = GK_SOUTHERN_ISLANDS; hasFP64 = true; hasFMAF = true; hasLDEXPF = true; } else { - DataLayoutString = DataLayoutStringR600; + resetDataLayout(DataLayoutStringR600); GPU = GK_R600; hasFP64 = false; hasFMAF = false; @@ -1940,7 +1919,7 @@ case GK_R700: case GK_EVERGREEN: case GK_NORTHERN_ISLANDS: - DataLayoutString = DataLayoutStringR600; + resetDataLayout(DataLayoutStringR600); hasFP64 = false; hasFMAF = false; hasLDEXPF = false; @@ -1949,7 +1928,7 @@ case GK_R700_DOUBLE_OPS: case GK_EVERGREEN_DOUBLE_OPS: case GK_CAYMAN: - DataLayoutString = DataLayoutStringR600DoubleOps; + resetDataLayout(DataLayoutStringR600DoubleOps); hasFP64 = true; hasFMAF = true; hasLDEXPF = false; @@ -1957,7 +1936,7 @@ case GK_SOUTHERN_ISLANDS: case GK_SEA_ISLANDS: case GK_VOLCANIC_ISLANDS: - DataLayoutString = DataLayoutStringSI; + resetDataLayout(DataLayoutStringSI); hasFP64 = true; hasFMAF = true; hasLDEXPF = true; @@ -3668,7 +3647,7 @@ LongDoubleWidth = 96; LongDoubleAlign = 32; SuitableAlign = 128; - DataLayoutString = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128"; + resetDataLayout("e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128"); SizeType = UnsignedInt; PtrDiffType = SignedInt; IntPtrType = SignedInt; @@ -3765,7 +3744,7 @@ UseSignedCharForObjCBool = false; SizeType = UnsignedLong; IntPtrType = SignedLong; - DataLayoutString = "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128"; + resetDataLayout("e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128"); HasAlignMac68kSupport = true; } @@ -3790,9 +3769,9 @@ DoubleAlign = LongLongAlign = 64; bool IsWinCOFF = getTriple().isOSWindows() && getTriple().isOSBinFormatCOFF(); - DataLayoutString = IsWinCOFF - ? "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32" - : "e-m:e-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"; + resetDataLayout(IsWinCOFF + ? "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32" + : "e-m:e-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"); } void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override { @@ -3871,7 +3850,7 @@ : X86_32TargetInfo(Triple) { WCharType = UnsignedShort; DoubleAlign = LongLongAlign = 64; - DataLayoutString = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"; + resetDataLayout("e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"); } void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override { @@ -3894,7 +3873,6 @@ IntPtrType = SignedLong; PtrDiffType = SignedLong; ProcessIDType = SignedLong; - this->UserLabelPrefix = ""; this->TLSSupported = false; } void getTargetDefines(const LangOptions &Opts, @@ -3911,9 +3889,7 @@ MCUX86_32TargetInfo(const llvm::Triple &Triple) : X86_32TargetInfo(Triple) { LongDoubleWidth = 64; LongDoubleFormat = &llvm::APFloat::IEEEdouble; - DataLayoutString = - "e-m:e-p:32:32-i64:32-f64:32-f128:32-n8:16:32-a:0:32-S32"; - UserLabelPrefix = ""; + resetDataLayout("e-m:e-p:32:32-i64:32-f64:32-f128:32-n8:16:32-a:0:32-S32"); WIntType = UnsignedInt; } @@ -3948,8 +3924,6 @@ public: RTEMSTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) { - this->UserLabelPrefix = ""; - switch (Triple.getArch()) { default: case llvm::Triple::x86: @@ -3976,7 +3950,6 @@ SizeType = UnsignedLong; IntPtrType = SignedLong; PtrDiffType = SignedLong; - this->UserLabelPrefix = ""; } void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override { @@ -4007,10 +3980,10 @@ RegParmMax = 6; // Pointers are 32-bit in x32. - DataLayoutString = IsX32 ? "e-m:e-p:32:32-i64:64-f80:128-n8:16:32:64-S128" - : IsWinCOFF - ? "e-m:w-i64:64-f80:128-n8:16:32:64-S128" - : "e-m:e-i64:64-f80:128-n8:16:32:64-S128"; + resetDataLayout(IsX32 + ? "e-m:e-p:32:32-i64:64-f80:128-n8:16:32:64-S128" + : IsWinCOFF ? "e-m:w-i64:64-f80:128-n8:16:32:64-S128" + : "e-m:e-i64:64-f80:128-n8:16:32:64-S128"); // Use fpret only for long double. RealTypeUsesObjCFPRet = (1 << TargetInfo::LongDouble); @@ -4081,7 +4054,6 @@ SizeType = UnsignedLongLong; PtrDiffType = SignedLongLong; IntPtrType = SignedLongLong; - this->UserLabelPrefix = ""; } void getTargetDefines(const LangOptions &Opts, @@ -4186,7 +4158,7 @@ llvm::Triple T = llvm::Triple(Triple); if (T.isiOS()) UseSignedCharForObjCBool = false; - DataLayoutString = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"; + resetDataLayout("e-m:o-i64:64-f80:128-n8:16:32:64-S128"); } bool handleTargetFeatures(std::vector &Features, @@ -4325,26 +4297,26 @@ // Thumb1 add sp, #imm requires the immediate value be multiple of 4, // so set preferred for small types to 32. if (T.isOSBinFormatMachO()) { - DataLayoutString = - BigEndian ? "E-m:o-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" - : "e-m:o-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"; + resetDataLayout(BigEndian + ? "E-m:o-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" + : "e-m:o-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"); } else if (T.isOSWindows()) { assert(!BigEndian && "Windows on ARM does not support big endian"); - DataLayoutString = "e" - "-m:w" - "-p:32:32" - "-i64:64" - "-v128:64:128" - "-a:0:32" - "-n32" - "-S64"; + resetDataLayout("e" + "-m:w" + "-p:32:32" + "-i64:64" + "-v128:64:128" + "-a:0:32" + "-n32" + "-S64"); } else if (T.isOSNaCl()) { assert(!BigEndian && "NaCl on ARM does not support big endian"); - DataLayoutString = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S128"; + resetDataLayout("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S128"); } else { - DataLayoutString = - BigEndian ? "E-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" - : "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"; + resetDataLayout(BigEndian + ? "E-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" + : "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"); } // FIXME: Enumerated types are variable width in straight AAPCS. @@ -4380,17 +4352,17 @@ if (T.isOSBinFormatMachO() && IsAAPCS16) { assert(!BigEndian && "AAPCS16 does not support big-endian"); - DataLayoutString = "e-m:o-p:32:32-i64:64-a:0:32-n32-S128"; + resetDataLayout("e-m:o-p:32:32-i64:64-a:0:32-n32-S128"); } else if (T.isOSBinFormatMachO()) - DataLayoutString = + resetDataLayout( BigEndian ? "E-m:o-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32" - : "e-m:o-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"; + : "e-m:o-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"); else - DataLayoutString = + resetDataLayout( BigEndian ? "E-m:e-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32" - : "e-m:e-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"; + : "e-m:e-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"); // FIXME: Override "preferred align" for double and long long. } @@ -5142,7 +5114,6 @@ : WindowsTargetInfo(Triple), Triple(Triple) { WCharType = UnsignedShort; SizeType = UnsignedInt; - UserLabelPrefix = ""; } void getVisualStudioDefines(const LangOptions &Opts, MacroBuilder &Builder) const { @@ -5238,7 +5209,7 @@ TLSSupported = false; WCharType = UnsignedShort; DoubleAlign = LongLongAlign = 64; - DataLayoutString = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"; + resetDataLayout("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"); } void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override { @@ -5285,7 +5256,7 @@ }; class AArch64TargetInfo : public TargetInfo { - virtual void setDataLayoutString() = 0; + virtual void setDataLayout() = 0; static const TargetInfo::GCCRegAlias GCCRegAliases[]; static const char *const GCCRegNames[]; @@ -5465,7 +5436,7 @@ V8_1A = 1; } - setDataLayoutString(); + setDataLayout(); return true; } @@ -5615,11 +5586,11 @@ }; class AArch64leTargetInfo : public AArch64TargetInfo { - void setDataLayoutString() override { + void setDataLayout() override { if (getTriple().isOSBinFormatMachO()) - DataLayoutString = "e-m:o-i64:64-i128:128-n32:64-S128"; + resetDataLayout("e-m:o-i64:64-i128:128-n32:64-S128"); else - DataLayoutString = "e-m:e-i64:64-i128:128-n32:64-S128"; + resetDataLayout("e-m:e-i64:64-i128:128-n32:64-S128"); } public: @@ -5635,9 +5606,9 @@ }; class AArch64beTargetInfo : public AArch64TargetInfo { - void setDataLayoutString() override { + void setDataLayout() override { assert(!getTriple().isOSBinFormatMachO()); - DataLayoutString = "E-m:e-i64:64-i128:128-n32:64-S128"; + resetDataLayout("E-m:e-i64:64-i128:128-n32:64-S128"); } public: @@ -5696,9 +5667,9 @@ public: HexagonTargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) { BigEndian = false; - DataLayoutString = "e-m:e-p:32:32:32-" - "i64:64:64-i32:32:32-i16:16:16-i1:8:8-" - "f64:64:64-f32:32:32-v64:64:64-v32:32:32-a:0-n16:32"; + resetDataLayout("e-m:e-p:32:32:32-" + "i64:64:64-i32:32:32-i16:16:16-i1:8:8-" + "f64:64:64-f32:32:32-v64:64:64-v32:32:32-a:0-n16:32"); SizeType = UnsignedInt; PtrDiffType = SignedInt; IntPtrType = SignedInt; @@ -6053,7 +6024,7 @@ class SparcV8TargetInfo : public SparcTargetInfo { public: SparcV8TargetInfo(const llvm::Triple &Triple) : SparcTargetInfo(Triple) { - DataLayoutString = "E-m:e-p:32:32-i64:64-f128:64-n32-S64"; + resetDataLayout("E-m:e-p:32:32-i64:64-f128:64-n32-S64"); // NetBSD / OpenBSD use long (same as llvm default); everyone else uses int. switch (getTriple().getOS()) { default: @@ -6094,7 +6065,7 @@ class SparcV8elTargetInfo : public SparcV8TargetInfo { public: SparcV8elTargetInfo(const llvm::Triple &Triple) : SparcV8TargetInfo(Triple) { - DataLayoutString = "e-m:e-p:32:32-i64:64-f128:64-n32-S64"; + resetDataLayout("e-m:e-p:32:32-i64:64-f128:64-n32-S64"); BigEndian = false; } }; @@ -6104,7 +6075,7 @@ public: SparcV9TargetInfo(const llvm::Triple &Triple) : SparcTargetInfo(Triple) { // FIXME: Support Sparc quad-precision long double? - DataLayoutString = "E-m:e-i64:64-n32:64-S128"; + resetDataLayout("E-m:e-i64:64-n32:64-S128"); // This is an LP64 platform. LongWidth = LongAlign = PointerWidth = PointerAlign = 64; @@ -6165,7 +6136,7 @@ LongDoubleFormat = &llvm::APFloat::IEEEquad; DefaultAlignForAttributeAligned = 64; MinGlobalAlign = 16; - DataLayoutString = "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64"; + resetDataLayout("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64"); MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64; } void getTargetDefines(const LangOptions &Opts, @@ -6240,8 +6211,8 @@ // If we use the vector ABI, vector types are 64-bit aligned. if (HasVector) { MaxVectorAlign = 64; - DataLayoutString = "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64" - "-v128:64-a:8:16-n32:64"; + resetDataLayout("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64" + "-v128:64-a:8:16-n32:64"); } return true; } @@ -6331,7 +6302,7 @@ IntPtrType = SignedInt; PtrDiffType = SignedInt; SigAtomicType = SignedLong; - DataLayoutString = "e-m:e-p:16:16-i32:16:32-a:16-n8:16"; + resetDataLayout("e-m:e-p:16:16-i32:16:32-a:16-n8:16"); } void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override { @@ -6424,8 +6395,8 @@ FloatFormat = &llvm::APFloat::IEEEsingle; DoubleFormat = &llvm::APFloat::IEEEsingle; LongDoubleFormat = &llvm::APFloat::IEEEsingle; - DataLayoutString = "E-p:32:32-i8:8:32-i16:16:32-i64:32" - "-f64:32-v64:32-v128:32-a:0:32-n32"; + resetDataLayout("E-p:32:32-i8:8:32-i16:16:32-i64:32" + "-f64:32-v64:32-v128:32-a:0:32-n32"); AddrSpaceMap = &TCEOpenCLAddrSpaceMap; UseAddrSpaceMapMangling = true; } @@ -6465,10 +6436,10 @@ RegParmMax = 5; if (Triple.getArch() == llvm::Triple::bpfeb) { BigEndian = true; - DataLayoutString = "E-m:e-p:64:64-i64:64-n32:64-S128"; + resetDataLayout("E-m:e-p:64:64-i64:64-n32:64-S128"); } else { BigEndian = false; - DataLayoutString = "e-m:e-p:64:64-i64:64-n32:64-S128"; + resetDataLayout("e-m:e-p:64:64-i64:64-n32:64-S128"); } MaxAtomicPromoteWidth = 64; MaxAtomicInlineWidth = 64; @@ -6503,7 +6474,7 @@ }; class MipsTargetInfoBase : public TargetInfo { - virtual void setDataLayoutString() = 0; + virtual void setDataLayout() = 0; static const Builtin::Info BuiltinInfo[]; std::string CPU; @@ -6797,7 +6768,7 @@ IsNan2008 = false; } - setDataLayoutString(); + setDataLayout(); return true; } @@ -6904,8 +6875,8 @@ }; class Mips32EBTargetInfo : public Mips32TargetInfoBase { - void setDataLayoutString() override { - DataLayoutString = "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64"; + void setDataLayout() override { + resetDataLayout("E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64"); } public: @@ -6921,8 +6892,8 @@ }; class Mips32ELTargetInfo : public Mips32TargetInfoBase { - void setDataLayoutString() override { - DataLayoutString = "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64"; + void setDataLayout() override { + resetDataLayout("e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64"); } public: @@ -7062,12 +7033,11 @@ }; class Mips64EBTargetInfo : public Mips64TargetInfoBase { - void setDataLayoutString() override { + void setDataLayout() override { if (ABI == "n32") - DataLayoutString = "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"; + resetDataLayout("E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"); else - DataLayoutString = "E-m:m-i8:8:32-i16:16:32-i64:64-n32:64-S128"; - + resetDataLayout("E-m:m-i8:8:32-i16:16:32-i64:64-n32:64-S128"); } public: @@ -7082,11 +7052,11 @@ }; class Mips64ELTargetInfo : public Mips64TargetInfoBase { - void setDataLayoutString() override { + void setDataLayout() override { if (ABI == "n32") - DataLayoutString = "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"; + resetDataLayout("e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"); else - DataLayoutString = "e-m:m-i8:8:32-i16:16:32-i64:64-n32:64-S128"; + resetDataLayout("e-m:m-i8:8:32-i16:16:32-i64:64-n32:64-S128"); } public: Mips64ELTargetInfo(const llvm::Triple &Triple) @@ -7106,7 +7076,6 @@ public: PNaClTargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) { BigEndian = false; - this->UserLabelPrefix = ""; this->LongAlign = 32; this->LongWidth = 32; this->PointerAlign = 32; @@ -7178,7 +7147,7 @@ NoAsmVariants = true; LongWidth = LongAlign = PointerWidth = PointerAlign = 64; MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64; - DataLayoutString = "e-m:e-v128:32-v16:16-v32:32-v96:32-n8:16:32:64-S128"; + resetDataLayout("e-m:e-v128:32-v16:16-v32:32-v96:32-n8:16:32:64-S128"); } void getTargetDefines(const LangOptions &Opts, @@ -7327,7 +7296,7 @@ explicit WebAssembly32TargetInfo(const llvm::Triple &T) : WebAssemblyTargetInfo(T) { MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32; - DataLayoutString = "e-m:e-p:32:32-i64:64-n32:64-S128"; + resetDataLayout("e-m:e-p:32:32-i64:64-n32:64-S128"); } protected: @@ -7345,7 +7314,7 @@ LongAlign = LongWidth = 64; PointerAlign = PointerWidth = 64; MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64; - DataLayoutString = "e-m:e-p:64:64-i64:64-n32:64-S128"; + resetDataLayout("e-m:e-p:64:64-i64:64-n32:64-S128"); } protected: @@ -7425,8 +7394,8 @@ PointerWidth = PointerAlign = 32; SizeType = TargetInfo::UnsignedInt; PtrDiffType = IntPtrType = TargetInfo::SignedInt; - DataLayoutString = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-" - "v96:128-v192:256-v256:256-v512:512-v1024:1024"; + resetDataLayout("e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-" + "v96:128-v192:256-v256:256-v512:512-v1024:1024"); } void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override { @@ -7440,8 +7409,8 @@ PointerWidth = PointerAlign = 64; SizeType = TargetInfo::UnsignedLong; PtrDiffType = IntPtrType = TargetInfo::SignedLong; - DataLayoutString = "e-i64:64-v16:16-v24:32-v32:32-v48:64-" - "v96:128-v192:256-v256:256-v512:512-v1024:1024"; + resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-" + "v96:128-v192:256-v256:256-v512:512-v1024:1024"); } void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override { @@ -7464,8 +7433,8 @@ WCharType = UnsignedChar; WIntType = UnsignedInt; UseZeroLengthBitfieldAlignment = true; - DataLayoutString = "e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i64:32" - "-f64:32-a:0:32-n32"; + resetDataLayout("e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i64:32" + "-f64:32-a:0:32-n32"); } void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override { Index: lib/CodeGen/BackendUtil.cpp =================================================================== --- lib/CodeGen/BackendUtil.cpp +++ lib/CodeGen/BackendUtil.cpp @@ -700,22 +700,22 @@ void clang::EmitBackendOutput(DiagnosticsEngine &Diags, const CodeGenOptions &CGOpts, const clang::TargetOptions &TOpts, - const LangOptions &LOpts, StringRef TDesc, + const LangOptions &LOpts, llvm::DataLayout TDesc, Module *M, BackendAction Action, raw_pwrite_stream *OS) { EmitAssemblyHelper AsmHelper(Diags, CGOpts, TOpts, LOpts, M); AsmHelper.EmitAssembly(Action, OS); - // If an optional clang TargetInfo description string was passed in, use it to - // verify the LLVM TargetMachine's DataLayout. - if (AsmHelper.TM && !TDesc.empty()) { + // Verify clang's TargetInfo DataLayout against the LLVM TargetMachine's + // DataLayout. + if (AsmHelper.TM) { std::string DLDesc = M->getDataLayout().getStringRepresentation(); - if (DLDesc != TDesc) { + if (DLDesc != TDesc.getStringRepresentation()) { unsigned DiagID = Diags.getCustomDiagID( DiagnosticsEngine::Error, "backend data layout '%0' does not match " "expected target description '%1'"); - Diags.Report(DiagID) << DLDesc << TDesc; + Diags.Report(DiagID) << DLDesc << TDesc.getStringRepresentation(); } } } Index: lib/CodeGen/CodeGenAction.cpp =================================================================== --- lib/CodeGen/CodeGenAction.cpp +++ lib/CodeGen/CodeGenAction.cpp @@ -187,8 +187,8 @@ } EmitBackendOutput(Diags, CodeGenOpts, TargetOpts, LangOpts, - C.getTargetInfo().getDataLayoutString(), - TheModule.get(), Action, AsmOutStream); + C.getTargetInfo().getDataLayout(), TheModule.get(), + Action, AsmOutStream); Ctx.setInlineAsmDiagnosticHandler(OldHandler, OldContext); @@ -839,7 +839,7 @@ LLVMContext &Ctx = TheModule->getContext(); Ctx.setInlineAsmDiagnosticHandler(BitcodeInlineAsmDiagHandler); EmitBackendOutput(CI.getDiagnostics(), CI.getCodeGenOpts(), TargetOpts, - CI.getLangOpts(), CI.getTarget().getDataLayoutString(), + CI.getLangOpts(), CI.getTarget().getDataLayout(), TheModule.get(), BA, OS); return; } Index: lib/CodeGen/ModuleBuilder.cpp =================================================================== --- lib/CodeGen/ModuleBuilder.cpp +++ lib/CodeGen/ModuleBuilder.cpp @@ -98,7 +98,7 @@ Ctx = &Context; M->setTargetTriple(Ctx->getTargetInfo().getTriple().getTriple()); - M->setDataLayout(Ctx->getTargetInfo().getDataLayoutString()); + M->setDataLayout(Ctx->getTargetInfo().getDataLayout()); Builder.reset(new CodeGen::CodeGenModule(Context, HeaderSearchOpts, PreprocessorOpts, CodeGenOpts, *M, Diags, CoverageInfo)); Index: lib/CodeGen/ObjectFilePCHContainerOperations.cpp =================================================================== --- lib/CodeGen/ObjectFilePCHContainerOperations.cpp +++ lib/CodeGen/ObjectFilePCHContainerOperations.cpp @@ -162,7 +162,7 @@ Ctx = &Context; VMContext.reset(new llvm::LLVMContext()); M.reset(new llvm::Module(MainFileName, *VMContext)); - M->setDataLayout(Ctx->getTargetInfo().getDataLayoutString()); + M->setDataLayout(Ctx->getTargetInfo().getDataLayout()); Builder.reset(new CodeGen::CodeGenModule( *Ctx, HeaderSearchOpts, PreprocessorOpts, CodeGenOpts, *M, Diags)); @@ -226,7 +226,7 @@ return; M->setTargetTriple(Ctx.getTargetInfo().getTriple().getTriple()); - M->setDataLayout(Ctx.getTargetInfo().getDataLayoutString()); + M->setDataLayout(Ctx.getTargetInfo().getDataLayout()); // PCH files don't have a signature field in the control block, // but LLVM detects DWO CUs by looking for a non-zero DWO id. @@ -272,15 +272,15 @@ llvm::SmallString<0> Buffer; llvm::raw_svector_ostream OS(Buffer); clang::EmitBackendOutput(Diags, CodeGenOpts, TargetOpts, LangOpts, - Ctx.getTargetInfo().getDataLayoutString(), - M.get(), BackendAction::Backend_EmitLL, &OS); + Ctx.getTargetInfo().getDataLayout(), M.get(), + BackendAction::Backend_EmitLL, &OS); llvm::dbgs() << Buffer; }); // Use the LLVM backend to emit the pch container. clang::EmitBackendOutput(Diags, CodeGenOpts, TargetOpts, LangOpts, - Ctx.getTargetInfo().getDataLayoutString(), - M.get(), BackendAction::Backend_EmitObj, OS); + Ctx.getTargetInfo().getDataLayout(), M.get(), + BackendAction::Backend_EmitObj, OS); // Make sure the pch container hits disk. OS->flush(); Index: lib/Frontend/InitPreprocessor.cpp =================================================================== --- lib/Frontend/InitPreprocessor.cpp +++ lib/Frontend/InitPreprocessor.cpp @@ -793,8 +793,8 @@ DefineFastIntType(64, true, TI, Builder); DefineFastIntType(64, false, TI, Builder); - if (const char *Prefix = TI.getUserLabelPrefix()) - Builder.defineMacro("__USER_LABEL_PREFIX__", Prefix); + char UserLabelPrefix[2] = {TI.getDataLayout().getGlobalPrefix(), 0}; + Builder.defineMacro("__USER_LABEL_PREFIX__", UserLabelPrefix); if (LangOpts.FastMath || LangOpts.FiniteMathOnly) Builder.defineMacro("__FINITE_MATH_ONLY__", "1"); Index: test/Preprocessor/init.c =================================================================== --- test/Preprocessor/init.c +++ test/Preprocessor/init.c @@ -423,7 +423,7 @@ // AARCH64:#define __UINT_LEAST64_TYPE__ long unsigned int // AARCH64:#define __UINT_LEAST8_MAX__ 255 // AARCH64:#define __UINT_LEAST8_TYPE__ unsigned char -// AARCH64:#define __USER_LABEL_PREFIX__ _ +// AARCH64:#define __USER_LABEL_PREFIX__ // AARCH64:#define __WCHAR_MAX__ 4294967295U // AARCH64:#define __WCHAR_TYPE__ unsigned int // AARCH64:#define __WCHAR_UNSIGNED__ 1 @@ -614,7 +614,7 @@ // AARCH64-BE:#define __UINT_LEAST64_TYPE__ long unsigned int // AARCH64-BE:#define __UINT_LEAST8_MAX__ 255 // AARCH64-BE:#define __UINT_LEAST8_TYPE__ unsigned char -// AARCH64-BE:#define __USER_LABEL_PREFIX__ _ +// AARCH64-BE:#define __USER_LABEL_PREFIX__ // AARCH64-BE:#define __WCHAR_MAX__ 4294967295U // AARCH64-BE:#define __WCHAR_TYPE__ unsigned int // AARCH64-BE:#define __WCHAR_UNSIGNED__ 1 @@ -1381,7 +1381,7 @@ // ARM:#define __UINT_LEAST64_TYPE__ long long unsigned int // ARM:#define __UINT_LEAST8_MAX__ 255 // ARM:#define __UINT_LEAST8_TYPE__ unsigned char -// ARM:#define __USER_LABEL_PREFIX__ _ +// ARM:#define __USER_LABEL_PREFIX__ // ARM:#define __WCHAR_MAX__ 4294967295U // ARM:#define __WCHAR_TYPE__ unsigned int // ARM:#define __WCHAR_WIDTH__ 32 @@ -1571,7 +1571,7 @@ // ARM-BE:#define __UINT_LEAST64_TYPE__ long long unsigned int // ARM-BE:#define __UINT_LEAST8_MAX__ 255 // ARM-BE:#define __UINT_LEAST8_TYPE__ unsigned char -// ARM-BE:#define __USER_LABEL_PREFIX__ _ +// ARM-BE:#define __USER_LABEL_PREFIX__ // ARM-BE:#define __WCHAR_MAX__ 4294967295U // ARM-BE:#define __WCHAR_TYPE__ unsigned int // ARM-BE:#define __WCHAR_WIDTH__ 32 @@ -2407,7 +2407,7 @@ // I386:#define __UINT_LEAST64_TYPE__ long long unsigned int // I386:#define __UINT_LEAST8_MAX__ 255 // I386:#define __UINT_LEAST8_TYPE__ unsigned char -// I386:#define __USER_LABEL_PREFIX__ _ +// I386:#define __USER_LABEL_PREFIX__ // I386:#define __WCHAR_MAX__ 2147483647 // I386:#define __WCHAR_TYPE__ int // I386:#define __WCHAR_WIDTH__ 32 @@ -2998,7 +2998,7 @@ // MIPS32BE:#define __UINT_LEAST64_TYPE__ long long unsigned int // MIPS32BE:#define __UINT_LEAST8_MAX__ 255 // MIPS32BE:#define __UINT_LEAST8_TYPE__ unsigned char -// MIPS32BE:#define __USER_LABEL_PREFIX__ _ +// MIPS32BE:#define __USER_LABEL_PREFIX__ // MIPS32BE:#define __WCHAR_MAX__ 2147483647 // MIPS32BE:#define __WCHAR_TYPE__ int // MIPS32BE:#define __WCHAR_WIDTH__ 32 @@ -3204,7 +3204,7 @@ // MIPS32EL:#define __UINT_LEAST64_TYPE__ long long unsigned int // MIPS32EL:#define __UINT_LEAST8_MAX__ 255 // MIPS32EL:#define __UINT_LEAST8_TYPE__ unsigned char -// MIPS32EL:#define __USER_LABEL_PREFIX__ _ +// MIPS32EL:#define __USER_LABEL_PREFIX__ // MIPS32EL:#define __WCHAR_MAX__ 2147483647 // MIPS32EL:#define __WCHAR_TYPE__ int // MIPS32EL:#define __WCHAR_WIDTH__ 32 @@ -3507,7 +3507,7 @@ // MIPSN32BE: #define __UINT_LEAST8_FMTx__ "hhx" // MIPSN32BE: #define __UINT_LEAST8_MAX__ 255 // MIPSN32BE: #define __UINT_LEAST8_TYPE__ unsigned char -// MIPSN32BE: #define __USER_LABEL_PREFIX__ _ +// MIPSN32BE: #define __USER_LABEL_PREFIX__ // MIPSN32BE: #define __WCHAR_MAX__ 2147483647 // MIPSN32BE: #define __WCHAR_TYPE__ int // MIPSN32BE: #define __WCHAR_WIDTH__ 32 @@ -3813,7 +3813,7 @@ // MIPSN32EL: #define __UINT_LEAST8_FMTx__ "hhx" // MIPSN32EL: #define __UINT_LEAST8_MAX__ 255 // MIPSN32EL: #define __UINT_LEAST8_TYPE__ unsigned char -// MIPSN32EL: #define __USER_LABEL_PREFIX__ _ +// MIPSN32EL: #define __USER_LABEL_PREFIX__ // MIPSN32EL: #define __WCHAR_MAX__ 2147483647 // MIPSN32EL: #define __WCHAR_TYPE__ int // MIPSN32EL: #define __WCHAR_WIDTH__ 32 @@ -4023,7 +4023,7 @@ // MIPS64BE:#define __UINT_LEAST64_TYPE__ long unsigned int // MIPS64BE:#define __UINT_LEAST8_MAX__ 255 // MIPS64BE:#define __UINT_LEAST8_TYPE__ unsigned char -// MIPS64BE:#define __USER_LABEL_PREFIX__ _ +// MIPS64BE:#define __USER_LABEL_PREFIX__ // MIPS64BE:#define __WCHAR_MAX__ 2147483647 // MIPS64BE:#define __WCHAR_TYPE__ int // MIPS64BE:#define __WCHAR_WIDTH__ 32 @@ -4232,7 +4232,7 @@ // MIPS64EL:#define __UINT_LEAST64_TYPE__ long unsigned int // MIPS64EL:#define __UINT_LEAST8_MAX__ 255 // MIPS64EL:#define __UINT_LEAST8_TYPE__ unsigned char -// MIPS64EL:#define __USER_LABEL_PREFIX__ _ +// MIPS64EL:#define __USER_LABEL_PREFIX__ // MIPS64EL:#define __WCHAR_MAX__ 2147483647 // MIPS64EL:#define __WCHAR_TYPE__ int // MIPS64EL:#define __WCHAR_WIDTH__ 32 @@ -4652,7 +4652,7 @@ // MSP430:#define __UINT_LEAST64_TYPE__ long long unsigned int // MSP430:#define __UINT_LEAST8_MAX__ 255 // MSP430:#define __UINT_LEAST8_TYPE__ unsigned char -// MSP430:#define __USER_LABEL_PREFIX__ _ +// MSP430:#define __USER_LABEL_PREFIX__ // MSP430:#define __WCHAR_MAX__ 32767 // MSP430:#define __WCHAR_TYPE__ int // MSP430:#define __WCHAR_WIDTH__ 16 @@ -4840,7 +4840,7 @@ // NVPTX32:#define __UINT_LEAST64_TYPE__ long long unsigned int // NVPTX32:#define __UINT_LEAST8_MAX__ 255 // NVPTX32:#define __UINT_LEAST8_TYPE__ unsigned char -// NVPTX32:#define __USER_LABEL_PREFIX__ _ +// NVPTX32:#define __USER_LABEL_PREFIX__ // NVPTX32:#define __WCHAR_MAX__ 2147483647 // NVPTX32:#define __WCHAR_TYPE__ int // NVPTX32:#define __WCHAR_WIDTH__ 32 @@ -5027,7 +5027,7 @@ // NVPTX64:#define __UINT_LEAST64_TYPE__ long unsigned int // NVPTX64:#define __UINT_LEAST8_MAX__ 255 // NVPTX64:#define __UINT_LEAST8_TYPE__ unsigned char -// NVPTX64:#define __USER_LABEL_PREFIX__ _ +// NVPTX64:#define __USER_LABEL_PREFIX__ // NVPTX64:#define __WCHAR_MAX__ 2147483647 // NVPTX64:#define __WCHAR_TYPE__ int // NVPTX64:#define __WCHAR_WIDTH__ 32 @@ -5219,7 +5219,7 @@ // PPC603E:#define __UINT_LEAST64_TYPE__ long long unsigned int // PPC603E:#define __UINT_LEAST8_MAX__ 255 // PPC603E:#define __UINT_LEAST8_TYPE__ unsigned char -// PPC603E:#define __USER_LABEL_PREFIX__ _ +// PPC603E:#define __USER_LABEL_PREFIX__ // PPC603E:#define __WCHAR_MAX__ 2147483647 // PPC603E:#define __WCHAR_TYPE__ int // PPC603E:#define __WCHAR_WIDTH__ 32 @@ -5419,7 +5419,7 @@ // PPC64:#define __UINT_LEAST64_TYPE__ long unsigned int // PPC64:#define __UINT_LEAST8_MAX__ 255 // PPC64:#define __UINT_LEAST8_TYPE__ unsigned char -// PPC64:#define __USER_LABEL_PREFIX__ _ +// PPC64:#define __USER_LABEL_PREFIX__ // PPC64:#define __WCHAR_MAX__ 2147483647 // PPC64:#define __WCHAR_TYPE__ int // PPC64:#define __WCHAR_WIDTH__ 32 @@ -5622,7 +5622,7 @@ // PPC64LE:#define __UINT_LEAST64_TYPE__ long unsigned int // PPC64LE:#define __UINT_LEAST8_MAX__ 255 // PPC64LE:#define __UINT_LEAST8_TYPE__ unsigned char -// PPC64LE:#define __USER_LABEL_PREFIX__ _ +// PPC64LE:#define __USER_LABEL_PREFIX__ // PPC64LE:#define __WCHAR_MAX__ 2147483647 // PPC64LE:#define __WCHAR_TYPE__ int // PPC64LE:#define __WCHAR_WIDTH__ 32 @@ -6209,7 +6209,7 @@ // PPC:#define __UINT_LEAST64_TYPE__ long long unsigned int // PPC:#define __UINT_LEAST8_MAX__ 255 // PPC:#define __UINT_LEAST8_TYPE__ unsigned char -// PPC:#define __USER_LABEL_PREFIX__ _ +// PPC:#define __USER_LABEL_PREFIX__ // PPC:#define __WCHAR_MAX__ 2147483647 // PPC:#define __WCHAR_TYPE__ int // PPC:#define __WCHAR_WIDTH__ 32 @@ -6788,7 +6788,7 @@ // S390X:#define __UINT_LEAST64_TYPE__ long unsigned int // S390X:#define __UINT_LEAST8_MAX__ 255 // S390X:#define __UINT_LEAST8_TYPE__ unsigned char -// S390X:#define __USER_LABEL_PREFIX__ _ +// S390X:#define __USER_LABEL_PREFIX__ // S390X:#define __WCHAR_MAX__ 2147483647 // S390X:#define __WCHAR_TYPE__ int // S390X:#define __WCHAR_WIDTH__ 32 @@ -6797,7 +6797,10 @@ // S390X:#define __s390__ 1 // S390X:#define __s390x__ 1 // -// RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc-none-none < /dev/null | FileCheck -match-full-lines -check-prefix SPARC %s +// RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc-none-none < /dev/null | FileCheck -match-full-lines -check-prefix SPARC -check-prefix SPARC-DEFAULT %s +// RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc-rtems-elf < /dev/null | FileCheck -match-full-lines -check-prefix SPARC -check-prefix SPARC-DEFAULT %s +// RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc-none-netbsd < /dev/null | FileCheck -match-full-lines -check-prefix SPARC -check-prefix SPARC-NETOPENBSD %s +// RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc-none-openbsd < /dev/null | FileCheck -match-full-lines -check-prefix SPARC -check-prefix SPARC-NETOPENBSD %s // // SPARC-NOT:#define _LP64 // SPARC:#define __BIGGEST_ALIGNMENT__ 8 @@ -6861,10 +6864,14 @@ // SPARC:#define __INTMAX_MAX__ 9223372036854775807LL // SPARC:#define __INTMAX_TYPE__ long long int // SPARC:#define __INTMAX_WIDTH__ 64 -// SPARC:#define __INTPTR_FMTd__ "d" -// SPARC:#define __INTPTR_FMTi__ "i" -// SPARC:#define __INTPTR_MAX__ 2147483647 -// SPARC:#define __INTPTR_TYPE__ int +// SPARC-DEFAULT:#define __INTPTR_FMTd__ "d" +// SPARC-DEFAULT:#define __INTPTR_FMTi__ "i" +// SPARC-DEFAULT:#define __INTPTR_MAX__ 2147483647 +// SPARC-DEFAULT:#define __INTPTR_TYPE__ int +// SPARC-NETOPENBSD:#define __INTPTR_FMTd__ "ld" +// SPARC-NETOPENBSD:#define __INTPTR_FMTi__ "li" +// SPARC-NETOPENBSD:#define __INTPTR_MAX__ 2147483647L +// SPARC-NETOPENBSD:#define __INTPTR_TYPE__ long int // SPARC:#define __INTPTR_WIDTH__ 32 // SPARC:#define __INT_FAST16_FMTd__ "hd" // SPARC:#define __INT_FAST16_FMTi__ "hi" @@ -6916,7 +6923,8 @@ // SPARC:#define __LONG_MAX__ 2147483647L // SPARC-NOT:#define __LP64__ // SPARC:#define __POINTER_WIDTH__ 32 -// SPARC:#define __PTRDIFF_TYPE__ int +// SPARC-DEFAULT:#define __PTRDIFF_TYPE__ int +// SPARC-NETOPENBSD:#define __PTRDIFF_TYPE__ long int // SPARC:#define __PTRDIFF_WIDTH__ 32 // SPARC:#define __REGISTER_PREFIX__ // SPARC:#define __SCHAR_MAX__ 127 @@ -6935,8 +6943,10 @@ // SPARC:#define __SIZEOF_SIZE_T__ 4 // SPARC:#define __SIZEOF_WCHAR_T__ 4 // SPARC:#define __SIZEOF_WINT_T__ 4 -// SPARC:#define __SIZE_MAX__ 4294967295U -// SPARC:#define __SIZE_TYPE__ unsigned int +// SPARC-DEFAULT:#define __SIZE_MAX__ 4294967295U +// SPARC-DEFAULT:#define __SIZE_TYPE__ unsigned int +// SPARC-NETOPENBSD:#define __SIZE_MAX__ 4294967295UL +// SPARC-NETOPENBSD:#define __SIZE_TYPE__ long unsigned int // SPARC:#define __SIZE_WIDTH__ 32 // SPARC:#define __UINT16_C_SUFFIX__ // SPARC:#define __UINT16_MAX__ 65535 @@ -6954,8 +6964,10 @@ // SPARC:#define __UINTMAX_MAX__ 18446744073709551615ULL // SPARC:#define __UINTMAX_TYPE__ long long unsigned int // SPARC:#define __UINTMAX_WIDTH__ 64 -// SPARC:#define __UINTPTR_MAX__ 4294967295U -// SPARC:#define __UINTPTR_TYPE__ unsigned int +// SPARC-DEFAULT:#define __UINTPTR_MAX__ 4294967295U +// SPARC-DEFAULT:#define __UINTPTR_TYPE__ unsigned int +// SPARC-NETOPENBSD:#define __UINTPTR_MAX__ 4294967295UL +// SPARC-NETOPENBSD:#define __UINTPTR_TYPE__ long unsigned int // SPARC:#define __UINTPTR_WIDTH__ 32 // SPARC:#define __UINT_FAST16_MAX__ 65535 // SPARC:#define __UINT_FAST16_TYPE__ unsigned short @@ -6973,7 +6985,7 @@ // SPARC:#define __UINT_LEAST64_TYPE__ long long unsigned int // SPARC:#define __UINT_LEAST8_MAX__ 255 // SPARC:#define __UINT_LEAST8_TYPE__ unsigned char -// SPARC:#define __USER_LABEL_PREFIX__ _ +// SPARC:#define __USER_LABEL_PREFIX__ // SPARC:#define __VERSION__ "4.2.1 Compatible{{.*}} // SPARC:#define __WCHAR_MAX__ 2147483647 // SPARC:#define __WCHAR_TYPE__ int @@ -6984,16 +6996,6 @@ // SPARC:#define __sparc__ 1 // SPARC:#define __sparcv8 1 // SPARC:#define sparc 1 -// -// RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc-none-netbsd < /dev/null | FileCheck -match-full-lines -check-prefix SPARC-NETOPENBSD %s -// RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc-none-openbsd < /dev/null | FileCheck -match-full-lines -check-prefix SPARC-NETOPENBSD %s -// SPARC-NETOPENBSD:#define __INTPTR_FMTd__ "ld" -// SPARC-NETOPENBSD:#define __INTPTR_FMTi__ "li" -// SPARC-NETOPENBSD:#define __INTPTR_MAX__ 2147483647L -// SPARC-NETOPENBSD:#define __INTPTR_TYPE__ long int -// SPARC-NETOPENBSD:#define __PTRDIFF_TYPE__ long int -// SPARC-NETOPENBSD:#define __SIZE_TYPE__ long unsigned int -// SPARC-NETOPENBSD:#define __UINTPTR_TYPE__ long unsigned int // RUN: %clang_cc1 -E -dM -ffreestanding -triple=tce-none-none < /dev/null | FileCheck -match-full-lines -check-prefix TCE %s // @@ -7152,7 +7154,7 @@ // TCE:#define __UINT_LEAST32_TYPE__ unsigned int // TCE:#define __UINT_LEAST8_MAX__ 255 // TCE:#define __UINT_LEAST8_TYPE__ unsigned char -// TCE:#define __USER_LABEL_PREFIX__ _ +// TCE:#define __USER_LABEL_PREFIX__ // TCE:#define __WCHAR_MAX__ 2147483647 // TCE:#define __WCHAR_TYPE__ int // TCE:#define __WCHAR_WIDTH__ 32 @@ -7346,7 +7348,7 @@ // X86_64:#define __UINT_LEAST64_TYPE__ long unsigned int // X86_64:#define __UINT_LEAST8_MAX__ 255 // X86_64:#define __UINT_LEAST8_TYPE__ unsigned char -// X86_64:#define __USER_LABEL_PREFIX__ _ +// X86_64:#define __USER_LABEL_PREFIX__ // X86_64:#define __WCHAR_MAX__ 2147483647 // X86_64:#define __WCHAR_TYPE__ int // X86_64:#define __WCHAR_WIDTH__ 32 @@ -7548,7 +7550,7 @@ // X32:#define __UINT_LEAST64_TYPE__ long long unsigned int // X32:#define __UINT_LEAST8_MAX__ 255 // X32:#define __UINT_LEAST8_TYPE__ unsigned char -// X32:#define __USER_LABEL_PREFIX__ _ +// X32:#define __USER_LABEL_PREFIX__ // X32:#define __WCHAR_MAX__ 2147483647 // X32:#define __WCHAR_TYPE__ int // X32:#define __WCHAR_WIDTH__ 32 Index: tools/libclang/CIndex.cpp =================================================================== --- tools/libclang/CIndex.cpp +++ tools/libclang/CIndex.cpp @@ -3977,7 +3977,7 @@ } static std::string getMangledStructor(std::unique_ptr &M, - std::unique_ptr &DL, + const llvm::DataLayout &DL, const NamedDecl *ND, unsigned StructorType) { std::string FrontendBuf; @@ -3991,13 +3991,13 @@ std::string BackendBuf; llvm::raw_string_ostream BOS(BackendBuf); - llvm::Mangler::getNameWithPrefix(BOS, llvm::Twine(FOS.str()), *DL); + llvm::Mangler::getNameWithPrefix(BOS, llvm::Twine(FOS.str()), DL); return BOS.str(); } static std::string getMangledName(std::unique_ptr &M, - std::unique_ptr &DL, + const llvm::DataLayout &DL, const NamedDecl *ND) { std::string FrontendBuf; llvm::raw_string_ostream FOS(FrontendBuf); @@ -4007,13 +4007,13 @@ std::string BackendBuf; llvm::raw_string_ostream BOS(BackendBuf); - llvm::Mangler::getNameWithPrefix(BOS, llvm::Twine(FOS.str()), *DL); + llvm::Mangler::getNameWithPrefix(BOS, llvm::Twine(FOS.str()), DL); return BOS.str(); } static std::string getMangledThunk(std::unique_ptr &M, - std::unique_ptr &DL, + const llvm::DataLayout &DL, const CXXMethodDecl *MD, const ThunkInfo &T) { std::string FrontendBuf; @@ -4024,7 +4024,7 @@ std::string BackendBuf; llvm::raw_string_ostream BOS(BackendBuf); - llvm::Mangler::getNameWithPrefix(BOS, llvm::Twine(FOS.str()), *DL); + llvm::Mangler::getNameWithPrefix(BOS, llvm::Twine(FOS.str()), DL); return BOS.str(); } @@ -4391,13 +4391,12 @@ } // Now apply backend mangling. - std::unique_ptr DL( - new llvm::DataLayout(Ctx.getTargetInfo().getDataLayoutString())); + const llvm::DataLayout &DL = Ctx.getTargetInfo().getDataLayout(); std::string FinalBuf; llvm::raw_string_ostream FinalBufOS(FinalBuf); llvm::Mangler::getNameWithPrefix(FinalBufOS, llvm::Twine(FrontendBufOS.str()), - *DL); + DL); return cxstring::createDup(FinalBufOS.str()); } @@ -4414,8 +4413,7 @@ ASTContext &Ctx = ND->getASTContext(); std::unique_ptr M(Ctx.createMangleContext()); - std::unique_ptr DL( - new llvm::DataLayout(Ctx.getTargetInfo().getDataLayoutString())); + const llvm::DataLayout &DL = Ctx.getTargetInfo().getDataLayout(); std::vector Manglings; Index: unittests/Basic/SourceManagerTest.cpp =================================================================== --- unittests/Basic/SourceManagerTest.cpp +++ unittests/Basic/SourceManagerTest.cpp @@ -23,7 +23,6 @@ #include "llvm/Config/llvm-config.h" #include "gtest/gtest.h" -using namespace llvm; using namespace clang; namespace { @@ -73,7 +72,8 @@ const char *source = "#define M(x) [x]\n" "M(foo)"; - std::unique_ptr Buf = MemoryBuffer::getMemBuffer(source); + std::unique_ptr Buf = + llvm::MemoryBuffer::getMemBuffer(source); FileID mainFileID = SourceMgr.createFileID(std::move(Buf)); SourceMgr.setMainFileID(mainFileID); @@ -126,7 +126,8 @@ "int x;\n" "int y;"; - std::unique_ptr Buf = MemoryBuffer::getMemBuffer(Source); + std::unique_ptr Buf = + llvm::MemoryBuffer::getMemBuffer(Source); FileID MainFileID = SourceMgr.createFileID(std::move(Buf)); SourceMgr.setMainFileID(MainFileID); @@ -185,8 +186,10 @@ "#define CONCAT(X, Y) X##Y\n" "CONCAT(1,1)\n"; - std::unique_ptr HeaderBuf = MemoryBuffer::getMemBuffer(header); - std::unique_ptr MainBuf = MemoryBuffer::getMemBuffer(main); + std::unique_ptr HeaderBuf = + llvm::MemoryBuffer::getMemBuffer(header); + std::unique_ptr MainBuf = + llvm::MemoryBuffer::getMemBuffer(main); FileID mainFileID = SourceMgr.createFileID(std::move(MainBuf)); SourceMgr.setMainFileID(mainFileID); @@ -284,8 +287,10 @@ "#define INC2 \n" "#include M(INC2)\n"; - std::unique_ptr HeaderBuf = MemoryBuffer::getMemBuffer(header); - std::unique_ptr MainBuf = MemoryBuffer::getMemBuffer(main); + std::unique_ptr HeaderBuf = + llvm::MemoryBuffer::getMemBuffer(header); + std::unique_ptr MainBuf = + llvm::MemoryBuffer::getMemBuffer(main); SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(MainBuf))); const FileEntry *headerFile = FileMgr.getVirtualFile("/test-header.h", Index: unittests/Lex/LexerTest.cpp =================================================================== --- unittests/Lex/LexerTest.cpp +++ unittests/Lex/LexerTest.cpp @@ -22,7 +22,6 @@ #include "clang/Lex/PreprocessorOptions.h" #include "gtest/gtest.h" -using namespace llvm; using namespace clang; namespace { @@ -61,7 +60,8 @@ std::vector CheckLex(StringRef Source, ArrayRef ExpectedTokens) { - std::unique_ptr Buf = MemoryBuffer::getMemBuffer(Source); + std::unique_ptr Buf = + llvm::MemoryBuffer::getMemBuffer(Source); SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(Buf))); VoidModuleLoader ModLoader; Index: unittests/Lex/PPConditionalDirectiveRecordTest.cpp =================================================================== --- unittests/Lex/PPConditionalDirectiveRecordTest.cpp +++ unittests/Lex/PPConditionalDirectiveRecordTest.cpp @@ -22,7 +22,6 @@ #include "clang/Lex/PreprocessorOptions.h" #include "gtest/gtest.h" -using namespace llvm; using namespace clang; namespace { @@ -89,7 +88,8 @@ "#endif\n" "9\n"; - std::unique_ptr Buf = MemoryBuffer::getMemBuffer(source); + std::unique_ptr Buf = + llvm::MemoryBuffer::getMemBuffer(source); SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(Buf))); VoidModuleLoader ModLoader;