forked from OSchip/llvm-project
[clang/Basic] Make TargetInfo.h not use DataLayout again
Reverts parts of https://reviews.llvm.org/D17183, but keeps the resetDataLayout() API and adds an assert that checks that datalayout string and user label prefix are in sync. Approach 1 in https://reviews.llvm.org/D17183#2653279 Reduces number of TUs build for 'clang-format' from 689 to 575. I also implemented approach 2 in D100764. If someone feels motivated to make us use DataLayout more, it's easy to revert this change here and go with D100764 instead. I don't plan on doing more work in this area though, so I prefer going with the smaller, more self-consistent change. Differential Revision: https://reviews.llvm.org/D100776
This commit is contained in:
parent
c35fadceab
commit
0f1137ba79
|
@ -40,7 +40,6 @@
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
struct fltSemantics;
|
struct fltSemantics;
|
||||||
class DataLayout;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace clang {
|
namespace clang {
|
||||||
|
@ -205,7 +204,8 @@ protected:
|
||||||
|
|
||||||
unsigned char MaxAtomicPromoteWidth, MaxAtomicInlineWidth;
|
unsigned char MaxAtomicPromoteWidth, MaxAtomicInlineWidth;
|
||||||
unsigned short SimdDefaultAlign;
|
unsigned short SimdDefaultAlign;
|
||||||
std::unique_ptr<llvm::DataLayout> DataLayout;
|
std::string DataLayoutString;
|
||||||
|
const char *UserLabelPrefix;
|
||||||
const char *MCountName;
|
const char *MCountName;
|
||||||
unsigned char RegParmMax, SSERegParmMax;
|
unsigned char RegParmMax, SSERegParmMax;
|
||||||
TargetCXXABI TheCXXABI;
|
TargetCXXABI TheCXXABI;
|
||||||
|
@ -238,7 +238,9 @@ protected:
|
||||||
// TargetInfo Constructor. Default initializes all fields.
|
// TargetInfo Constructor. Default initializes all fields.
|
||||||
TargetInfo(const llvm::Triple &T);
|
TargetInfo(const llvm::Triple &T);
|
||||||
|
|
||||||
void resetDataLayout(StringRef DL);
|
// UserLabelPrefix must match DL's getGlobalPrefix() when interpreted
|
||||||
|
// as a DataLayout object.
|
||||||
|
void resetDataLayout(StringRef DL, const char *UserLabelPrefix = "");
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// Construct a target for the given options.
|
/// Construct a target for the given options.
|
||||||
|
@ -747,6 +749,12 @@ public:
|
||||||
return PointerWidth;
|
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.
|
||||||
|
const char *getUserLabelPrefix() const { return UserLabelPrefix; }
|
||||||
|
|
||||||
/// Returns the name of the mcount instrumentation function.
|
/// Returns the name of the mcount instrumentation function.
|
||||||
const char *getMCountName() const {
|
const char *getMCountName() const {
|
||||||
return MCountName;
|
return MCountName;
|
||||||
|
@ -1096,9 +1104,9 @@ public:
|
||||||
/// Returns the target ID if supported.
|
/// Returns the target ID if supported.
|
||||||
virtual llvm::Optional<std::string> getTargetID() const { return llvm::None; }
|
virtual llvm::Optional<std::string> getTargetID() const { return llvm::None; }
|
||||||
|
|
||||||
const llvm::DataLayout &getDataLayout() const {
|
const char *getDataLayoutString() const {
|
||||||
assert(DataLayout && "Uninitialized DataLayout!");
|
assert(!DataLayoutString.empty() && "Uninitialized DataLayout!");
|
||||||
return *DataLayout;
|
return DataLayoutString.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct GCCRegAlias {
|
struct GCCRegAlias {
|
||||||
|
|
|
@ -39,8 +39,7 @@ namespace clang {
|
||||||
void EmitBackendOutput(DiagnosticsEngine &Diags, const HeaderSearchOptions &,
|
void EmitBackendOutput(DiagnosticsEngine &Diags, const HeaderSearchOptions &,
|
||||||
const CodeGenOptions &CGOpts,
|
const CodeGenOptions &CGOpts,
|
||||||
const TargetOptions &TOpts, const LangOptions &LOpts,
|
const TargetOptions &TOpts, const LangOptions &LOpts,
|
||||||
const llvm::DataLayout &TDesc, llvm::Module *M,
|
StringRef TDesc, llvm::Module *M, BackendAction Action,
|
||||||
BackendAction Action,
|
|
||||||
std::unique_ptr<raw_pwrite_stream> OS);
|
std::unique_ptr<raw_pwrite_stream> OS);
|
||||||
|
|
||||||
void EmbedBitcode(llvm::Module *M, const CodeGenOptions &CGOpts,
|
void EmbedBitcode(llvm::Module *M, const CodeGenOptions &CGOpts,
|
||||||
|
|
|
@ -139,7 +139,9 @@ bool MangleContext::shouldMangleDeclName(const NamedDecl *D) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MangleContext::mangleName(GlobalDecl GD, raw_ostream &Out) {
|
void MangleContext::mangleName(GlobalDecl GD, raw_ostream &Out) {
|
||||||
|
const ASTContext &ASTContext = getASTContext();
|
||||||
const NamedDecl *D = cast<NamedDecl>(GD.getDecl());
|
const NamedDecl *D = cast<NamedDecl>(GD.getDecl());
|
||||||
|
|
||||||
// Any decl can be declared with __asm("foo") on it, and this takes precedence
|
// Any decl can be declared with __asm("foo") on it, and this takes precedence
|
||||||
// over all other naming in the .o file.
|
// over all other naming in the .o file.
|
||||||
if (const AsmLabelAttr *ALA = D->getAttr<AsmLabelAttr>()) {
|
if (const AsmLabelAttr *ALA = D->getAttr<AsmLabelAttr>()) {
|
||||||
|
@ -157,9 +159,16 @@ void MangleContext::mangleName(GlobalDecl GD, raw_ostream &Out) {
|
||||||
// tricks normally used for producing aliases (PR9177). Fortunately the
|
// tricks normally used for producing aliases (PR9177). Fortunately the
|
||||||
// llvm mangler on ELF is a nop, so we can just avoid adding the \01
|
// llvm mangler on ELF is a nop, so we can just avoid adding the \01
|
||||||
// marker.
|
// marker.
|
||||||
|
StringRef UserLabelPrefix =
|
||||||
|
getASTContext().getTargetInfo().getUserLabelPrefix();
|
||||||
|
#ifndef NDEBUG
|
||||||
char GlobalPrefix =
|
char GlobalPrefix =
|
||||||
getASTContext().getTargetInfo().getDataLayout().getGlobalPrefix();
|
llvm::DataLayout(getASTContext().getTargetInfo().getDataLayoutString())
|
||||||
if (GlobalPrefix)
|
.getGlobalPrefix();
|
||||||
|
assert((UserLabelPrefix.empty() && !GlobalPrefix) ||
|
||||||
|
(UserLabelPrefix.size() == 1 && UserLabelPrefix[0] == GlobalPrefix));
|
||||||
|
#endif
|
||||||
|
if (!UserLabelPrefix.empty())
|
||||||
Out << '\01'; // LLVM IR Marker for __asm("foo")
|
Out << '\01'; // LLVM IR Marker for __asm("foo")
|
||||||
|
|
||||||
Out << ALA->getLabel();
|
Out << ALA->getLabel();
|
||||||
|
@ -169,7 +178,6 @@ void MangleContext::mangleName(GlobalDecl GD, raw_ostream &Out) {
|
||||||
if (auto *GD = dyn_cast<MSGuidDecl>(D))
|
if (auto *GD = dyn_cast<MSGuidDecl>(D))
|
||||||
return mangleMSGuidDecl(GD, Out);
|
return mangleMSGuidDecl(GD, Out);
|
||||||
|
|
||||||
const ASTContext &ASTContext = getASTContext();
|
|
||||||
CCMangling CC = getCallingConvMangling(ASTContext, D);
|
CCMangling CC = getCallingConvMangling(ASTContext, D);
|
||||||
|
|
||||||
if (CC == CCM_WasmMainArgcArgv) {
|
if (CC == CCM_WasmMainArgcArgv) {
|
||||||
|
@ -383,8 +391,8 @@ class ASTNameGenerator::Implementation {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Implementation(ASTContext &Ctx)
|
explicit Implementation(ASTContext &Ctx)
|
||||||
: MC(Ctx.createMangleContext()), DL(Ctx.getTargetInfo().getDataLayout()) {
|
: MC(Ctx.createMangleContext()),
|
||||||
}
|
DL(Ctx.getTargetInfo().getDataLayoutString()) {}
|
||||||
|
|
||||||
bool writeName(const Decl *D, raw_ostream &OS) {
|
bool writeName(const Decl *D, raw_ostream &OS) {
|
||||||
// First apply frontend mangling.
|
// First apply frontend mangling.
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
set(LLVM_LINK_COMPONENTS
|
set(LLVM_LINK_COMPONENTS
|
||||||
Core
|
|
||||||
MC
|
MC
|
||||||
Support
|
Support
|
||||||
)
|
)
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
#include "clang/Basic/LangOptions.h"
|
#include "clang/Basic/LangOptions.h"
|
||||||
#include "llvm/ADT/APFloat.h"
|
#include "llvm/ADT/APFloat.h"
|
||||||
#include "llvm/ADT/STLExtras.h"
|
#include "llvm/ADT/STLExtras.h"
|
||||||
#include "llvm/IR/DataLayout.h"
|
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
#include "llvm/Support/TargetParser.h"
|
#include "llvm/Support/TargetParser.h"
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
@ -114,6 +113,7 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : TargetOpts(), Triple(T) {
|
||||||
LongDoubleFormat = &llvm::APFloat::IEEEdouble();
|
LongDoubleFormat = &llvm::APFloat::IEEEdouble();
|
||||||
Float128Format = &llvm::APFloat::IEEEquad();
|
Float128Format = &llvm::APFloat::IEEEquad();
|
||||||
MCountName = "mcount";
|
MCountName = "mcount";
|
||||||
|
UserLabelPrefix = "_";
|
||||||
RegParmMax = 0;
|
RegParmMax = 0;
|
||||||
SSERegParmMax = 0;
|
SSERegParmMax = 0;
|
||||||
HasAlignMac68kSupport = false;
|
HasAlignMac68kSupport = false;
|
||||||
|
@ -149,8 +149,9 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : TargetOpts(), Triple(T) {
|
||||||
// Out of line virtual dtor for TargetInfo.
|
// Out of line virtual dtor for TargetInfo.
|
||||||
TargetInfo::~TargetInfo() {}
|
TargetInfo::~TargetInfo() {}
|
||||||
|
|
||||||
void TargetInfo::resetDataLayout(StringRef DL) {
|
void TargetInfo::resetDataLayout(StringRef DL, const char *ULP) {
|
||||||
DataLayout.reset(new llvm::DataLayout(DL));
|
DataLayoutString = DL.str();
|
||||||
|
UserLabelPrefix = ULP;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
@ -745,9 +745,9 @@ AArch64leTargetInfo::AArch64leTargetInfo(const llvm::Triple &Triple,
|
||||||
void AArch64leTargetInfo::setDataLayout() {
|
void AArch64leTargetInfo::setDataLayout() {
|
||||||
if (getTriple().isOSBinFormatMachO()) {
|
if (getTriple().isOSBinFormatMachO()) {
|
||||||
if(getTriple().isArch32Bit())
|
if(getTriple().isArch32Bit())
|
||||||
resetDataLayout("e-m:o-p:32:32-i64:64-i128:128-n32:64-S128");
|
resetDataLayout("e-m:o-p:32:32-i64:64-i128:128-n32:64-S128", "_");
|
||||||
else
|
else
|
||||||
resetDataLayout("e-m:o-i64:64-i128:128-n32:64-S128");
|
resetDataLayout("e-m:o-i64:64-i128:128-n32:64-S128", "_");
|
||||||
} else
|
} else
|
||||||
resetDataLayout("e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128");
|
resetDataLayout("e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128");
|
||||||
}
|
}
|
||||||
|
@ -796,7 +796,8 @@ WindowsARM64TargetInfo::WindowsARM64TargetInfo(const llvm::Triple &Triple,
|
||||||
void WindowsARM64TargetInfo::setDataLayout() {
|
void WindowsARM64TargetInfo::setDataLayout() {
|
||||||
resetDataLayout(Triple.isOSBinFormatMachO()
|
resetDataLayout(Triple.isOSBinFormatMachO()
|
||||||
? "e-m:o-i64:64-i128:128-n32:64-S128"
|
? "e-m:o-i64:64-i128:128-n32:64-S128"
|
||||||
: "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128");
|
: "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128",
|
||||||
|
Triple.isOSBinFormatMachO() ? "_" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
TargetInfo::BuiltinVaListKind
|
TargetInfo::BuiltinVaListKind
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
#include "clang/Basic/TargetBuiltins.h"
|
#include "clang/Basic/TargetBuiltins.h"
|
||||||
#include "llvm/ADT/StringSwitch.h"
|
#include "llvm/ADT/StringSwitch.h"
|
||||||
#include "llvm/Frontend/OpenMP/OMPGridValues.h"
|
#include "llvm/Frontend/OpenMP/OMPGridValues.h"
|
||||||
#include "llvm/IR/DataLayout.h"
|
|
||||||
|
|
||||||
using namespace clang;
|
using namespace clang;
|
||||||
using namespace clang::targets;
|
using namespace clang::targets;
|
||||||
|
@ -329,7 +328,6 @@ AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple &Triple,
|
||||||
llvm::AMDGPU::getArchAttrR600(GPUKind)) {
|
llvm::AMDGPU::getArchAttrR600(GPUKind)) {
|
||||||
resetDataLayout(isAMDGCN(getTriple()) ? DataLayoutStringAMDGCN
|
resetDataLayout(isAMDGCN(getTriple()) ? DataLayoutStringAMDGCN
|
||||||
: DataLayoutStringR600);
|
: DataLayoutStringR600);
|
||||||
assert(DataLayout->getAllocaAddrSpace() == Private);
|
|
||||||
GridValues = llvm::omp::AMDGPUGpuGridValues;
|
GridValues = llvm::omp::AMDGPUGpuGridValues;
|
||||||
|
|
||||||
setAddressSpaceMap(Triple.getOS() == llvm::Triple::Mesa3D ||
|
setAddressSpaceMap(Triple.getOS() == llvm::Triple::Mesa3D ||
|
||||||
|
@ -342,7 +340,7 @@ AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple &Triple,
|
||||||
AllowAMDGPUUnsafeFPAtomics = Opts.AllowAMDGPUUnsafeFPAtomics;
|
AllowAMDGPUUnsafeFPAtomics = Opts.AllowAMDGPUUnsafeFPAtomics;
|
||||||
|
|
||||||
// Set pointer width and alignment for target address space 0.
|
// Set pointer width and alignment for target address space 0.
|
||||||
PointerWidth = PointerAlign = DataLayout->getPointerSizeInBits();
|
PointerWidth = PointerAlign = getPointerWidthV(Generic);
|
||||||
if (getMaxPointerWidth() == 64) {
|
if (getMaxPointerWidth() == 64) {
|
||||||
LongWidth = LongAlign = 64;
|
LongWidth = LongAlign = 64;
|
||||||
SizeType = UnsignedLong;
|
SizeType = UnsignedLong;
|
||||||
|
|
|
@ -44,7 +44,8 @@ void ARMTargetInfo::setABIAAPCS() {
|
||||||
if (T.isOSBinFormatMachO()) {
|
if (T.isOSBinFormatMachO()) {
|
||||||
resetDataLayout(BigEndian
|
resetDataLayout(BigEndian
|
||||||
? "E-m:o-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
|
? "E-m:o-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
|
||||||
: "e-m:o-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64");
|
: "e-m:o-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64",
|
||||||
|
"_");
|
||||||
} else if (T.isOSWindows()) {
|
} else if (T.isOSWindows()) {
|
||||||
assert(!BigEndian && "Windows on ARM does not support big endian");
|
assert(!BigEndian && "Windows on ARM does not support big endian");
|
||||||
resetDataLayout("e"
|
resetDataLayout("e"
|
||||||
|
@ -93,12 +94,13 @@ void ARMTargetInfo::setABIAPCS(bool IsAAPCS16) {
|
||||||
|
|
||||||
if (T.isOSBinFormatMachO() && IsAAPCS16) {
|
if (T.isOSBinFormatMachO() && IsAAPCS16) {
|
||||||
assert(!BigEndian && "AAPCS16 does not support big-endian");
|
assert(!BigEndian && "AAPCS16 does not support big-endian");
|
||||||
resetDataLayout("e-m:o-p:32:32-Fi8-i64:64-a:0:32-n32-S128");
|
resetDataLayout("e-m:o-p:32:32-Fi8-i64:64-a:0:32-n32-S128", "_");
|
||||||
} else if (T.isOSBinFormatMachO())
|
} else if (T.isOSBinFormatMachO())
|
||||||
resetDataLayout(
|
resetDataLayout(
|
||||||
BigEndian
|
BigEndian
|
||||||
? "E-m:o-p:32:32-Fi8-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"
|
? "E-m:o-p:32:32-Fi8-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"
|
||||||
: "e-m:o-p:32:32-Fi8-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32");
|
: "e-m:o-p:32:32-Fi8-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32",
|
||||||
|
"_");
|
||||||
else
|
else
|
||||||
resetDataLayout(
|
resetDataLayout(
|
||||||
BigEndian
|
BigEndian
|
||||||
|
|
|
@ -468,7 +468,7 @@ public:
|
||||||
BoolWidth = BoolAlign = 32; // XXX support -mone-byte-bool?
|
BoolWidth = BoolAlign = 32; // XXX support -mone-byte-bool?
|
||||||
PtrDiffType = SignedInt; // for http://llvm.org/bugs/show_bug.cgi?id=15726
|
PtrDiffType = SignedInt; // for http://llvm.org/bugs/show_bug.cgi?id=15726
|
||||||
LongLongAlign = 32;
|
LongLongAlign = 32;
|
||||||
resetDataLayout("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 {
|
BuiltinVaListKind getBuiltinVaListKind() const override {
|
||||||
|
@ -482,7 +482,7 @@ public:
|
||||||
DarwinPPC64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
|
DarwinPPC64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
|
||||||
: DarwinTargetInfo<PPC64TargetInfo>(Triple, Opts) {
|
: DarwinTargetInfo<PPC64TargetInfo>(Triple, Opts) {
|
||||||
HasAlignMac68kSupport = true;
|
HasAlignMac68kSupport = true;
|
||||||
resetDataLayout("E-m:o-i64:64-n32:64");
|
resetDataLayout("E-m:o-i64:64-n32:64", "_");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -386,11 +386,13 @@ public:
|
||||||
LongDoubleWidth = 96;
|
LongDoubleWidth = 96;
|
||||||
LongDoubleAlign = 32;
|
LongDoubleAlign = 32;
|
||||||
SuitableAlign = 128;
|
SuitableAlign = 128;
|
||||||
resetDataLayout(Triple.isOSBinFormatMachO() ?
|
resetDataLayout(
|
||||||
"e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-"
|
Triple.isOSBinFormatMachO()
|
||||||
"f80:32-n8:16:32-S128" :
|
? "e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-"
|
||||||
"e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-"
|
"f80:32-n8:16:32-S128"
|
||||||
"f80:32-n8:16:32-S128");
|
: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-"
|
||||||
|
"f80:32-n8:16:32-S128",
|
||||||
|
Triple.isOSBinFormatMachO() ? "_" : "");
|
||||||
SizeType = UnsignedInt;
|
SizeType = UnsignedInt;
|
||||||
PtrDiffType = SignedInt;
|
PtrDiffType = SignedInt;
|
||||||
IntPtrType = SignedInt;
|
IntPtrType = SignedInt;
|
||||||
|
@ -494,7 +496,7 @@ public:
|
||||||
SizeType = UnsignedLong;
|
SizeType = UnsignedLong;
|
||||||
IntPtrType = SignedLong;
|
IntPtrType = SignedLong;
|
||||||
resetDataLayout("e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-"
|
resetDataLayout("e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-"
|
||||||
"f80:128-n8:16:32-S128");
|
"f80:128-n8:16:32-S128", "_");
|
||||||
HasAlignMac68kSupport = true;
|
HasAlignMac68kSupport = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -522,7 +524,8 @@ public:
|
||||||
resetDataLayout(IsWinCOFF ? "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:"
|
resetDataLayout(IsWinCOFF ? "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:"
|
||||||
"64-i64:64-f80:32-n8:16:32-a:0:32-S32"
|
"64-i64:64-f80:32-n8:16:32-a:0:32-S32"
|
||||||
: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:"
|
: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:"
|
||||||
"64-i64:64-f80:32-n8:16:32-a:0:32-S32");
|
"64-i64:64-f80:32-n8:16:32-a:0:32-S32",
|
||||||
|
IsWinCOFF ? "_" : "");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -571,7 +574,8 @@ public:
|
||||||
this->WCharType = TargetInfo::UnsignedShort;
|
this->WCharType = TargetInfo::UnsignedShort;
|
||||||
DoubleAlign = LongLongAlign = 64;
|
DoubleAlign = LongLongAlign = 64;
|
||||||
resetDataLayout("e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:"
|
resetDataLayout("e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:"
|
||||||
"32-n8:16:32-a:0:32-S32");
|
"32-n8:16:32-a:0:32-S32",
|
||||||
|
"_");
|
||||||
}
|
}
|
||||||
|
|
||||||
void getTargetDefines(const LangOptions &Opts,
|
void getTargetDefines(const LangOptions &Opts,
|
||||||
|
@ -866,7 +870,7 @@ public:
|
||||||
if (T.isiOS())
|
if (T.isiOS())
|
||||||
UseSignedCharForObjCBool = false;
|
UseSignedCharForObjCBool = false;
|
||||||
resetDataLayout("e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:"
|
resetDataLayout("e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:"
|
||||||
"16:32:64-S128");
|
"16:32:64-S128", "_");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool handleTargetFeatures(std::vector<std::string> &Features,
|
bool handleTargetFeatures(std::vector<std::string> &Features,
|
||||||
|
|
|
@ -1600,7 +1600,7 @@ void clang::EmitBackendOutput(DiagnosticsEngine &Diags,
|
||||||
const CodeGenOptions &CGOpts,
|
const CodeGenOptions &CGOpts,
|
||||||
const clang::TargetOptions &TOpts,
|
const clang::TargetOptions &TOpts,
|
||||||
const LangOptions &LOpts,
|
const LangOptions &LOpts,
|
||||||
const llvm::DataLayout &TDesc, Module *M,
|
StringRef TDesc, Module *M,
|
||||||
BackendAction Action,
|
BackendAction Action,
|
||||||
std::unique_ptr<raw_pwrite_stream> OS) {
|
std::unique_ptr<raw_pwrite_stream> OS) {
|
||||||
|
|
||||||
|
@ -1654,11 +1654,11 @@ void clang::EmitBackendOutput(DiagnosticsEngine &Diags,
|
||||||
// DataLayout.
|
// DataLayout.
|
||||||
if (AsmHelper.TM) {
|
if (AsmHelper.TM) {
|
||||||
std::string DLDesc = M->getDataLayout().getStringRepresentation();
|
std::string DLDesc = M->getDataLayout().getStringRepresentation();
|
||||||
if (DLDesc != TDesc.getStringRepresentation()) {
|
if (DLDesc != TDesc) {
|
||||||
unsigned DiagID = Diags.getCustomDiagID(
|
unsigned DiagID = Diags.getCustomDiagID(
|
||||||
DiagnosticsEngine::Error, "backend data layout '%0' does not match "
|
DiagnosticsEngine::Error, "backend data layout '%0' does not match "
|
||||||
"expected target description '%1'");
|
"expected target description '%1'");
|
||||||
Diags.Report(DiagID) << DLDesc << TDesc.getStringRepresentation();
|
Diags.Report(DiagID) << DLDesc << TDesc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -332,7 +332,7 @@ namespace clang {
|
||||||
EmbedBitcode(getModule(), CodeGenOpts, llvm::MemoryBufferRef());
|
EmbedBitcode(getModule(), CodeGenOpts, llvm::MemoryBufferRef());
|
||||||
|
|
||||||
EmitBackendOutput(Diags, HeaderSearchOpts, CodeGenOpts, TargetOpts,
|
EmitBackendOutput(Diags, HeaderSearchOpts, CodeGenOpts, TargetOpts,
|
||||||
LangOpts, C.getTargetInfo().getDataLayout(),
|
LangOpts, C.getTargetInfo().getDataLayoutString(),
|
||||||
getModule(), Action, std::move(AsmOutStream));
|
getModule(), Action, std::move(AsmOutStream));
|
||||||
|
|
||||||
Ctx.setDiagnosticHandler(std::move(OldDiagnosticHandler));
|
Ctx.setDiagnosticHandler(std::move(OldDiagnosticHandler));
|
||||||
|
@ -1105,7 +1105,7 @@ void CodeGenAction::ExecuteAction() {
|
||||||
|
|
||||||
EmitBackendOutput(Diagnostics, CI.getHeaderSearchOpts(), CodeGenOpts,
|
EmitBackendOutput(Diagnostics, CI.getHeaderSearchOpts(), CodeGenOpts,
|
||||||
TargetOpts, CI.getLangOpts(),
|
TargetOpts, CI.getLangOpts(),
|
||||||
CI.getTarget().getDataLayout(), TheModule.get(), BA,
|
CI.getTarget().getDataLayoutString(), TheModule.get(), BA,
|
||||||
std::move(OS));
|
std::move(OS));
|
||||||
if (OptRecordFile)
|
if (OptRecordFile)
|
||||||
OptRecordFile->keep();
|
OptRecordFile->keep();
|
||||||
|
|
|
@ -138,7 +138,7 @@ namespace {
|
||||||
Ctx = &Context;
|
Ctx = &Context;
|
||||||
|
|
||||||
M->setTargetTriple(Ctx->getTargetInfo().getTriple().getTriple());
|
M->setTargetTriple(Ctx->getTargetInfo().getTriple().getTriple());
|
||||||
M->setDataLayout(Ctx->getTargetInfo().getDataLayout());
|
M->setDataLayout(Ctx->getTargetInfo().getDataLayoutString());
|
||||||
const auto &SDKVersion = Ctx->getTargetInfo().getSDKVersion();
|
const auto &SDKVersion = Ctx->getTargetInfo().getSDKVersion();
|
||||||
if (!SDKVersion.empty())
|
if (!SDKVersion.empty())
|
||||||
M->setSDKVersion(SDKVersion);
|
M->setSDKVersion(SDKVersion);
|
||||||
|
|
|
@ -166,7 +166,7 @@ public:
|
||||||
Ctx = &Context;
|
Ctx = &Context;
|
||||||
VMContext.reset(new llvm::LLVMContext());
|
VMContext.reset(new llvm::LLVMContext());
|
||||||
M.reset(new llvm::Module(MainFileName, *VMContext));
|
M.reset(new llvm::Module(MainFileName, *VMContext));
|
||||||
M->setDataLayout(Ctx->getTargetInfo().getDataLayout());
|
M->setDataLayout(Ctx->getTargetInfo().getDataLayoutString());
|
||||||
Builder.reset(new CodeGen::CodeGenModule(
|
Builder.reset(new CodeGen::CodeGenModule(
|
||||||
*Ctx, HeaderSearchOpts, PreprocessorOpts, CodeGenOpts, *M, Diags));
|
*Ctx, HeaderSearchOpts, PreprocessorOpts, CodeGenOpts, *M, Diags));
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ public:
|
||||||
return;
|
return;
|
||||||
|
|
||||||
M->setTargetTriple(Ctx.getTargetInfo().getTriple().getTriple());
|
M->setTargetTriple(Ctx.getTargetInfo().getTriple().getTriple());
|
||||||
M->setDataLayout(Ctx.getTargetInfo().getDataLayout());
|
M->setDataLayout(Ctx.getTargetInfo().getDataLayoutString());
|
||||||
|
|
||||||
// PCH files don't have a signature field in the control block,
|
// 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.
|
// but LLVM detects DWO CUs by looking for a non-zero DWO id.
|
||||||
|
@ -295,7 +295,7 @@ public:
|
||||||
llvm::SmallString<0> Buffer;
|
llvm::SmallString<0> Buffer;
|
||||||
clang::EmitBackendOutput(
|
clang::EmitBackendOutput(
|
||||||
Diags, HeaderSearchOpts, CodeGenOpts, TargetOpts, LangOpts,
|
Diags, HeaderSearchOpts, CodeGenOpts, TargetOpts, LangOpts,
|
||||||
Ctx.getTargetInfo().getDataLayout(), M.get(),
|
Ctx.getTargetInfo().getDataLayoutString(), M.get(),
|
||||||
BackendAction::Backend_EmitLL,
|
BackendAction::Backend_EmitLL,
|
||||||
std::make_unique<llvm::raw_svector_ostream>(Buffer));
|
std::make_unique<llvm::raw_svector_ostream>(Buffer));
|
||||||
llvm::dbgs() << Buffer;
|
llvm::dbgs() << Buffer;
|
||||||
|
@ -303,9 +303,9 @@ public:
|
||||||
|
|
||||||
// Use the LLVM backend to emit the pch container.
|
// Use the LLVM backend to emit the pch container.
|
||||||
clang::EmitBackendOutput(Diags, HeaderSearchOpts, CodeGenOpts, TargetOpts,
|
clang::EmitBackendOutput(Diags, HeaderSearchOpts, CodeGenOpts, TargetOpts,
|
||||||
LangOpts, Ctx.getTargetInfo().getDataLayout(),
|
LangOpts,
|
||||||
M.get(), BackendAction::Backend_EmitObj,
|
Ctx.getTargetInfo().getDataLayoutString(), M.get(),
|
||||||
std::move(OS));
|
BackendAction::Backend_EmitObj, std::move(OS));
|
||||||
|
|
||||||
// Free the memory for the temporary buffer.
|
// Free the memory for the temporary buffer.
|
||||||
llvm::SmallVector<char, 0> Empty;
|
llvm::SmallVector<char, 0> Empty;
|
||||||
|
|
|
@ -985,8 +985,7 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
|
||||||
DefineFastIntType(64, true, TI, Builder);
|
DefineFastIntType(64, true, TI, Builder);
|
||||||
DefineFastIntType(64, false, TI, Builder);
|
DefineFastIntType(64, false, TI, Builder);
|
||||||
|
|
||||||
char UserLabelPrefix[2] = {TI.getDataLayout().getGlobalPrefix(), 0};
|
Builder.defineMacro("__USER_LABEL_PREFIX__", TI.getUserLabelPrefix());
|
||||||
Builder.defineMacro("__USER_LABEL_PREFIX__", UserLabelPrefix);
|
|
||||||
|
|
||||||
if (LangOpts.FastMath || LangOpts.FiniteMathOnly)
|
if (LangOpts.FastMath || LangOpts.FiniteMathOnly)
|
||||||
Builder.defineMacro("__FINITE_MATH_ONLY__", "1");
|
Builder.defineMacro("__FINITE_MATH_ONLY__", "1");
|
||||||
|
|
|
@ -75,7 +75,7 @@ TEST(Decl, AsmLabelAttr) {
|
||||||
auto AST =
|
auto AST =
|
||||||
tooling::buildASTFromCodeWithArgs(Code, {"-target", "i386-apple-darwin"});
|
tooling::buildASTFromCodeWithArgs(Code, {"-target", "i386-apple-darwin"});
|
||||||
ASTContext &Ctx = AST->getASTContext();
|
ASTContext &Ctx = AST->getASTContext();
|
||||||
assert(Ctx.getTargetInfo().getDataLayout().getGlobalPrefix() &&
|
assert(Ctx.getTargetInfo().getUserLabelPrefix() == StringRef("_") &&
|
||||||
"Expected target to have a global prefix");
|
"Expected target to have a global prefix");
|
||||||
DiagnosticsEngine &Diags = AST->getDiagnostics();
|
DiagnosticsEngine &Diags = AST->getDiagnostics();
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ TEST(Decl, MangleDependentSizedArray) {
|
||||||
auto AST =
|
auto AST =
|
||||||
tooling::buildASTFromCodeWithArgs(Code, {"-target", "i386-apple-darwin"});
|
tooling::buildASTFromCodeWithArgs(Code, {"-target", "i386-apple-darwin"});
|
||||||
ASTContext &Ctx = AST->getASTContext();
|
ASTContext &Ctx = AST->getASTContext();
|
||||||
assert(Ctx.getTargetInfo().getDataLayout().getGlobalPrefix() &&
|
assert(Ctx.getTargetInfo().getUserLabelPrefix() == StringRef("_") &&
|
||||||
"Expected target to have a global prefix");
|
"Expected target to have a global prefix");
|
||||||
DiagnosticsEngine &Diags = AST->getDiagnostics();
|
DiagnosticsEngine &Diags = AST->getDiagnostics();
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,6 @@ static_library("Basic") {
|
||||||
"//clang/include/clang/Sema:AttrParsedAttrKinds",
|
"//clang/include/clang/Sema:AttrParsedAttrKinds",
|
||||||
"//clang/include/clang/Sema:AttrSpellingListIndex",
|
"//clang/include/clang/Sema:AttrSpellingListIndex",
|
||||||
"//llvm/include/llvm/Config:llvm-config",
|
"//llvm/include/llvm/Config:llvm-config",
|
||||||
"//llvm/lib/IR",
|
|
||||||
"//llvm/lib/MC",
|
"//llvm/lib/MC",
|
||||||
"//llvm/lib/Support",
|
"//llvm/lib/Support",
|
||||||
]
|
]
|
||||||
|
|
|
@ -11,6 +11,7 @@ executable("clang-format") {
|
||||||
"//clang/lib/AST/",
|
"//clang/lib/AST/",
|
||||||
"//clang/lib/Frontend/",
|
"//clang/lib/Frontend/",
|
||||||
"//clang/lib/Sema/",
|
"//clang/lib/Sema/",
|
||||||
|
"//llvm/lib/IR",
|
||||||
]
|
]
|
||||||
sources = [ "ClangFormat.cpp" ]
|
sources = [ "ClangFormat.cpp" ]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue