forked from OSchip/llvm-project
[clang][TargetInfo] Use LangAS for getPointer{Width,Align}()
Mixing LLVM and Clang address spaces can result in subtle bugs, and there is no need for this hook to use the LLVM IR level address spaces. Most of this change is just replacing zero with LangAS::Default, but it also allows us to remove a few calls to getTargetAddressSpace(). This also removes a stale comment+workaround in CGDebugInfo::CreatePointerLikeType(): ASTContext::getTypeSize() does return the expected size for ReferenceType (and handles address spaces). Differential Revision: https://reviews.llvm.org/D138295
This commit is contained in:
parent
57b1c0250d
commit
a602f76a24
|
@ -357,10 +357,11 @@ public:
|
||||||
IntType getUIntMaxType() const {
|
IntType getUIntMaxType() const {
|
||||||
return getCorrespondingUnsignedType(IntMaxType);
|
return getCorrespondingUnsignedType(IntMaxType);
|
||||||
}
|
}
|
||||||
IntType getPtrDiffType(unsigned AddrSpace) const {
|
IntType getPtrDiffType(LangAS AddrSpace) const {
|
||||||
return AddrSpace == 0 ? PtrDiffType : getPtrDiffTypeV(AddrSpace);
|
return AddrSpace == LangAS::Default ? PtrDiffType
|
||||||
|
: getPtrDiffTypeV(AddrSpace);
|
||||||
}
|
}
|
||||||
IntType getUnsignedPtrDiffType(unsigned AddrSpace) const {
|
IntType getUnsignedPtrDiffType(LangAS AddrSpace) const {
|
||||||
return getCorrespondingUnsignedType(getPtrDiffType(AddrSpace));
|
return getCorrespondingUnsignedType(getPtrDiffType(AddrSpace));
|
||||||
}
|
}
|
||||||
IntType getIntPtrType() const { return IntPtrType; }
|
IntType getIntPtrType() const { return IntPtrType; }
|
||||||
|
@ -438,11 +439,13 @@ public:
|
||||||
|
|
||||||
/// Return the width of pointers on this target, for the
|
/// Return the width of pointers on this target, for the
|
||||||
/// specified address space.
|
/// specified address space.
|
||||||
uint64_t getPointerWidth(unsigned AddrSpace) const {
|
uint64_t getPointerWidth(LangAS AddrSpace) const {
|
||||||
return AddrSpace == 0 ? PointerWidth : getPointerWidthV(AddrSpace);
|
return AddrSpace == LangAS::Default ? PointerWidth
|
||||||
|
: getPointerWidthV(AddrSpace);
|
||||||
}
|
}
|
||||||
uint64_t getPointerAlign(unsigned AddrSpace) const {
|
uint64_t getPointerAlign(LangAS AddrSpace) const {
|
||||||
return AddrSpace == 0 ? PointerAlign : getPointerAlignV(AddrSpace);
|
return AddrSpace == LangAS::Default ? PointerAlign
|
||||||
|
: getPointerAlignV(AddrSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the maximum width of pointers on this target.
|
/// Return the maximum width of pointers on this target.
|
||||||
|
@ -604,7 +607,8 @@ public:
|
||||||
|
|
||||||
/// Determine whether the __int128 type is supported on this target.
|
/// Determine whether the __int128 type is supported on this target.
|
||||||
virtual bool hasInt128Type() const {
|
virtual bool hasInt128Type() const {
|
||||||
return (getPointerWidth(0) >= 64) || getTargetOpts().ForceEnableInt128;
|
return (getPointerWidth(LangAS::Default) >= 64) ||
|
||||||
|
getTargetOpts().ForceEnableInt128;
|
||||||
} // FIXME
|
} // FIXME
|
||||||
|
|
||||||
/// Determine whether the _BitInt type is supported on this target. This
|
/// Determine whether the _BitInt type is supported on this target. This
|
||||||
|
@ -822,7 +826,9 @@ public:
|
||||||
unsigned getProgramAddressSpace() const { return ProgramAddrSpace; }
|
unsigned getProgramAddressSpace() const { return ProgramAddrSpace; }
|
||||||
|
|
||||||
// Return the size of unwind_word for this target.
|
// Return the size of unwind_word for this target.
|
||||||
virtual unsigned getUnwindWordWidth() const { return getPointerWidth(0); }
|
virtual unsigned getUnwindWordWidth() const {
|
||||||
|
return getPointerWidth(LangAS::Default);
|
||||||
|
}
|
||||||
|
|
||||||
/// Return the "preferred" register width on this target.
|
/// Return the "preferred" register width on this target.
|
||||||
virtual unsigned getRegisterWidth() const {
|
virtual unsigned getRegisterWidth() const {
|
||||||
|
@ -1485,6 +1491,11 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
const LangASMap &getAddressSpaceMap() const { return *AddrSpaceMap; }
|
const LangASMap &getAddressSpaceMap() const { return *AddrSpaceMap; }
|
||||||
|
unsigned getTargetAddressSpace(LangAS AS) const {
|
||||||
|
if (isTargetAddressSpace(AS))
|
||||||
|
return toTargetAddressSpace(AS);
|
||||||
|
return getAddressSpaceMap()[(unsigned)AS];
|
||||||
|
}
|
||||||
|
|
||||||
/// Map from the address space field in builtin description strings to the
|
/// Map from the address space field in builtin description strings to the
|
||||||
/// language address space.
|
/// language address space.
|
||||||
|
@ -1685,13 +1696,13 @@ public:
|
||||||
protected:
|
protected:
|
||||||
/// Copy type and layout related info.
|
/// Copy type and layout related info.
|
||||||
void copyAuxTarget(const TargetInfo *Aux);
|
void copyAuxTarget(const TargetInfo *Aux);
|
||||||
virtual uint64_t getPointerWidthV(unsigned AddrSpace) const {
|
virtual uint64_t getPointerWidthV(LangAS AddrSpace) const {
|
||||||
return PointerWidth;
|
return PointerWidth;
|
||||||
}
|
}
|
||||||
virtual uint64_t getPointerAlignV(unsigned AddrSpace) const {
|
virtual uint64_t getPointerAlignV(LangAS AddrSpace) const {
|
||||||
return PointerAlign;
|
return PointerAlign;
|
||||||
}
|
}
|
||||||
virtual enum IntType getPtrDiffTypeV(unsigned AddrSpace) const {
|
virtual enum IntType getPtrDiffTypeV(LangAS AddrSpace) const {
|
||||||
return PtrDiffType;
|
return PtrDiffType;
|
||||||
}
|
}
|
||||||
virtual ArrayRef<const char *> getGCCRegNames() const = 0;
|
virtual ArrayRef<const char *> getGCCRegNames() const = 0;
|
||||||
|
|
|
@ -1879,7 +1879,7 @@ static getConstantArrayInfoInChars(const ASTContext &Context,
|
||||||
uint64_t Width = EltInfo.Width.getQuantity() * Size;
|
uint64_t Width = EltInfo.Width.getQuantity() * Size;
|
||||||
unsigned Align = EltInfo.Align.getQuantity();
|
unsigned Align = EltInfo.Align.getQuantity();
|
||||||
if (!Context.getTargetInfo().getCXXABI().isMicrosoft() ||
|
if (!Context.getTargetInfo().getCXXABI().isMicrosoft() ||
|
||||||
Context.getTargetInfo().getPointerWidth(0) == 64)
|
Context.getTargetInfo().getPointerWidth(LangAS::Default) == 64)
|
||||||
Width = llvm::alignTo(Width, Align);
|
Width = llvm::alignTo(Width, Align);
|
||||||
return TypeInfoChars(CharUnits::fromQuantity(Width),
|
return TypeInfoChars(CharUnits::fromQuantity(Width),
|
||||||
CharUnits::fromQuantity(Align),
|
CharUnits::fromQuantity(Align),
|
||||||
|
@ -1990,7 +1990,7 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const {
|
||||||
uint64_t Width = 0;
|
uint64_t Width = 0;
|
||||||
unsigned Align = 8;
|
unsigned Align = 8;
|
||||||
AlignRequirementKind AlignRequirement = AlignRequirementKind::None;
|
AlignRequirementKind AlignRequirement = AlignRequirementKind::None;
|
||||||
unsigned AS = 0;
|
LangAS AS = LangAS::Default;
|
||||||
switch (T->getTypeClass()) {
|
switch (T->getTypeClass()) {
|
||||||
#define TYPE(Class, Base)
|
#define TYPE(Class, Base)
|
||||||
#define ABSTRACT_TYPE(Class, Base)
|
#define ABSTRACT_TYPE(Class, Base)
|
||||||
|
@ -2025,7 +2025,7 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const {
|
||||||
Align = EltInfo.Align;
|
Align = EltInfo.Align;
|
||||||
AlignRequirement = EltInfo.AlignRequirement;
|
AlignRequirement = EltInfo.AlignRequirement;
|
||||||
if (!getTargetInfo().getCXXABI().isMicrosoft() ||
|
if (!getTargetInfo().getCXXABI().isMicrosoft() ||
|
||||||
getTargetInfo().getPointerWidth(0) == 64)
|
getTargetInfo().getPointerWidth(LangAS::Default) == 64)
|
||||||
Width = llvm::alignTo(Width, Align);
|
Width = llvm::alignTo(Width, Align);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2225,14 +2225,15 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BuiltinType::NullPtr:
|
case BuiltinType::NullPtr:
|
||||||
Width = Target->getPointerWidth(0); // C++ 3.9.1p11: sizeof(nullptr_t)
|
// C++ 3.9.1p11: sizeof(nullptr_t) == sizeof(void*)
|
||||||
Align = Target->getPointerAlign(0); // == sizeof(void*)
|
Width = Target->getPointerWidth(LangAS::Default);
|
||||||
|
Align = Target->getPointerAlign(LangAS::Default);
|
||||||
break;
|
break;
|
||||||
case BuiltinType::ObjCId:
|
case BuiltinType::ObjCId:
|
||||||
case BuiltinType::ObjCClass:
|
case BuiltinType::ObjCClass:
|
||||||
case BuiltinType::ObjCSel:
|
case BuiltinType::ObjCSel:
|
||||||
Width = Target->getPointerWidth(0);
|
Width = Target->getPointerWidth(LangAS::Default);
|
||||||
Align = Target->getPointerAlign(0);
|
Align = Target->getPointerAlign(LangAS::Default);
|
||||||
break;
|
break;
|
||||||
case BuiltinType::OCLSampler:
|
case BuiltinType::OCLSampler:
|
||||||
case BuiltinType::OCLEvent:
|
case BuiltinType::OCLEvent:
|
||||||
|
@ -2245,8 +2246,7 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const {
|
||||||
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
|
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
|
||||||
case BuiltinType::Id:
|
case BuiltinType::Id:
|
||||||
#include "clang/Basic/OpenCLExtensionTypes.def"
|
#include "clang/Basic/OpenCLExtensionTypes.def"
|
||||||
AS = getTargetAddressSpace(
|
AS = Target->getOpenCLTypeAddrSpace(getOpenCLTypeKind(T));
|
||||||
Target->getOpenCLTypeAddrSpace(getOpenCLTypeKind(T)));
|
|
||||||
Width = Target->getPointerWidth(AS);
|
Width = Target->getPointerWidth(AS);
|
||||||
Align = Target->getPointerAlign(AS);
|
Align = Target->getPointerAlign(AS);
|
||||||
break;
|
break;
|
||||||
|
@ -2291,11 +2291,11 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Type::ObjCObjectPointer:
|
case Type::ObjCObjectPointer:
|
||||||
Width = Target->getPointerWidth(0);
|
Width = Target->getPointerWidth(LangAS::Default);
|
||||||
Align = Target->getPointerAlign(0);
|
Align = Target->getPointerAlign(LangAS::Default);
|
||||||
break;
|
break;
|
||||||
case Type::BlockPointer:
|
case Type::BlockPointer:
|
||||||
AS = getTargetAddressSpace(cast<BlockPointerType>(T)->getPointeeType());
|
AS = cast<BlockPointerType>(T)->getPointeeType().getAddressSpace();
|
||||||
Width = Target->getPointerWidth(AS);
|
Width = Target->getPointerWidth(AS);
|
||||||
Align = Target->getPointerAlign(AS);
|
Align = Target->getPointerAlign(AS);
|
||||||
break;
|
break;
|
||||||
|
@ -2303,12 +2303,12 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const {
|
||||||
case Type::RValueReference:
|
case Type::RValueReference:
|
||||||
// alignof and sizeof should never enter this code path here, so we go
|
// alignof and sizeof should never enter this code path here, so we go
|
||||||
// the pointer route.
|
// the pointer route.
|
||||||
AS = getTargetAddressSpace(cast<ReferenceType>(T)->getPointeeType());
|
AS = cast<ReferenceType>(T)->getPointeeType().getAddressSpace();
|
||||||
Width = Target->getPointerWidth(AS);
|
Width = Target->getPointerWidth(AS);
|
||||||
Align = Target->getPointerAlign(AS);
|
Align = Target->getPointerAlign(AS);
|
||||||
break;
|
break;
|
||||||
case Type::Pointer:
|
case Type::Pointer:
|
||||||
AS = getTargetAddressSpace(cast<PointerType>(T)->getPointeeType());
|
AS = cast<PointerType>(T)->getPointeeType().getAddressSpace();
|
||||||
Width = Target->getPointerWidth(AS);
|
Width = Target->getPointerWidth(AS);
|
||||||
Align = Target->getPointerAlign(AS);
|
Align = Target->getPointerAlign(AS);
|
||||||
break;
|
break;
|
||||||
|
@ -2465,8 +2465,8 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Type::Pipe:
|
case Type::Pipe:
|
||||||
Width = Target->getPointerWidth(getTargetAddressSpace(LangAS::opencl_global));
|
Width = Target->getPointerWidth(LangAS::opencl_global);
|
||||||
Align = Target->getPointerAlign(getTargetAddressSpace(LangAS::opencl_global));
|
Align = Target->getPointerAlign(LangAS::opencl_global);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5975,14 +5975,14 @@ QualType ASTContext::getUIntPtrType() const {
|
||||||
/// getPointerDiffType - Return the unique type for "ptrdiff_t" (C99 7.17)
|
/// getPointerDiffType - Return the unique type for "ptrdiff_t" (C99 7.17)
|
||||||
/// defined in <stddef.h>. Pointer - pointer requires this (C99 6.5.6p9).
|
/// defined in <stddef.h>. Pointer - pointer requires this (C99 6.5.6p9).
|
||||||
QualType ASTContext::getPointerDiffType() const {
|
QualType ASTContext::getPointerDiffType() const {
|
||||||
return getFromTargetType(Target->getPtrDiffType(0));
|
return getFromTargetType(Target->getPtrDiffType(LangAS::Default));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the unique unsigned counterpart of "ptrdiff_t"
|
/// Return the unique unsigned counterpart of "ptrdiff_t"
|
||||||
/// integer type. The standard (C11 7.21.6.1p7) refers to this type
|
/// integer type. The standard (C11 7.21.6.1p7) refers to this type
|
||||||
/// in the definition of %tu format specifier.
|
/// in the definition of %tu format specifier.
|
||||||
QualType ASTContext::getUnsignedPointerDiffType() const {
|
QualType ASTContext::getUnsignedPointerDiffType() const {
|
||||||
return getFromTargetType(Target->getUnsignedPtrDiffType(0));
|
return getFromTargetType(Target->getUnsignedPtrDiffType(LangAS::Default));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the unique type for "pid_t" defined in
|
/// Return the unique type for "pid_t" defined in
|
||||||
|
|
|
@ -224,7 +224,7 @@ public:
|
||||||
MemberPointerInfo
|
MemberPointerInfo
|
||||||
getMemberPointerInfo(const MemberPointerType *MPT) const override {
|
getMemberPointerInfo(const MemberPointerType *MPT) const override {
|
||||||
const TargetInfo &Target = Context.getTargetInfo();
|
const TargetInfo &Target = Context.getTargetInfo();
|
||||||
TargetInfo::IntType PtrDiff = Target.getPtrDiffType(0);
|
TargetInfo::IntType PtrDiff = Target.getPtrDiffType(LangAS::Default);
|
||||||
MemberPointerInfo MPI;
|
MemberPointerInfo MPI;
|
||||||
MPI.Width = Target.getTypeWidth(PtrDiff);
|
MPI.Width = Target.getTypeWidth(PtrDiff);
|
||||||
MPI.Align = Target.getTypeAlign(PtrDiff);
|
MPI.Align = Target.getTypeAlign(PtrDiff);
|
||||||
|
@ -251,8 +251,8 @@ public:
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD);
|
const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD);
|
||||||
CharUnits PointerSize =
|
CharUnits PointerSize = Context.toCharUnitsFromBits(
|
||||||
Context.toCharUnitsFromBits(Context.getTargetInfo().getPointerWidth(0));
|
Context.getTargetInfo().getPointerWidth(LangAS::Default));
|
||||||
return Layout.getNonVirtualSize() == PointerSize;
|
return Layout.getNonVirtualSize() == PointerSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -223,6 +223,7 @@ void MangleContext::mangleName(GlobalDecl GD, raw_ostream &Out) {
|
||||||
if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD))
|
if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD))
|
||||||
if (!MD->isStatic())
|
if (!MD->isStatic())
|
||||||
++ArgWords;
|
++ArgWords;
|
||||||
|
uint64_t DefaultPtrWidth = TI.getPointerWidth(LangAS::Default);
|
||||||
for (const auto &AT : Proto->param_types()) {
|
for (const auto &AT : Proto->param_types()) {
|
||||||
// If an argument type is incomplete there is no way to get its size to
|
// If an argument type is incomplete there is no way to get its size to
|
||||||
// correctly encode into the mangling scheme.
|
// correctly encode into the mangling scheme.
|
||||||
|
@ -230,11 +231,10 @@ void MangleContext::mangleName(GlobalDecl GD, raw_ostream &Out) {
|
||||||
if (AT->isIncompleteType())
|
if (AT->isIncompleteType())
|
||||||
break;
|
break;
|
||||||
// Size should be aligned to pointer size.
|
// Size should be aligned to pointer size.
|
||||||
ArgWords +=
|
ArgWords += llvm::alignTo(ASTContext.getTypeSize(AT), DefaultPtrWidth) /
|
||||||
llvm::alignTo(ASTContext.getTypeSize(AT), TI.getPointerWidth(0)) /
|
DefaultPtrWidth;
|
||||||
TI.getPointerWidth(0);
|
|
||||||
}
|
}
|
||||||
Out << ((TI.getPointerWidth(0) / 8) * ArgWords);
|
Out << ((DefaultPtrWidth / 8) * ArgWords);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MangleContext::mangleMSGuidDecl(const MSGuidDecl *GD, raw_ostream &Out) {
|
void MangleContext::mangleMSGuidDecl(const MSGuidDecl *GD, raw_ostream &Out) {
|
||||||
|
|
|
@ -303,7 +303,7 @@ CXXABI::MemberPointerInfo MicrosoftCXXABI::getMemberPointerInfo(
|
||||||
// The nominal struct is laid out with pointers followed by ints and aligned
|
// The nominal struct is laid out with pointers followed by ints and aligned
|
||||||
// to a pointer width if any are present and an int width otherwise.
|
// to a pointer width if any are present and an int width otherwise.
|
||||||
const TargetInfo &Target = Context.getTargetInfo();
|
const TargetInfo &Target = Context.getTargetInfo();
|
||||||
unsigned PtrSize = Target.getPointerWidth(0);
|
unsigned PtrSize = Target.getPointerWidth(LangAS::Default);
|
||||||
unsigned IntSize = Target.getIntWidth();
|
unsigned IntSize = Target.getIntWidth();
|
||||||
|
|
||||||
unsigned Ptrs, Ints;
|
unsigned Ptrs, Ints;
|
||||||
|
@ -318,7 +318,7 @@ CXXABI::MemberPointerInfo MicrosoftCXXABI::getMemberPointerInfo(
|
||||||
if (Ptrs + Ints > 1 && Target.getTriple().isArch32Bit())
|
if (Ptrs + Ints > 1 && Target.getTriple().isArch32Bit())
|
||||||
MPI.Align = 64;
|
MPI.Align = 64;
|
||||||
else if (Ptrs)
|
else if (Ptrs)
|
||||||
MPI.Align = Target.getPointerAlign(0);
|
MPI.Align = Target.getPointerAlign(LangAS::Default);
|
||||||
else
|
else
|
||||||
MPI.Align = Target.getIntAlign();
|
MPI.Align = Target.getIntAlign();
|
||||||
|
|
||||||
|
|
|
@ -340,22 +340,22 @@ public:
|
||||||
MicrosoftCXXNameMangler(MicrosoftMangleContextImpl &C, raw_ostream &Out_)
|
MicrosoftCXXNameMangler(MicrosoftMangleContextImpl &C, raw_ostream &Out_)
|
||||||
: Context(C), Out(Out_), Structor(nullptr), StructorType(-1),
|
: Context(C), Out(Out_), Structor(nullptr), StructorType(-1),
|
||||||
TemplateArgStringStorage(TemplateArgStringStorageAlloc),
|
TemplateArgStringStorage(TemplateArgStringStorageAlloc),
|
||||||
PointersAre64Bit(C.getASTContext().getTargetInfo().getPointerWidth(0) ==
|
PointersAre64Bit(C.getASTContext().getTargetInfo().getPointerWidth(
|
||||||
64) {}
|
LangAS::Default) == 64) {}
|
||||||
|
|
||||||
MicrosoftCXXNameMangler(MicrosoftMangleContextImpl &C, raw_ostream &Out_,
|
MicrosoftCXXNameMangler(MicrosoftMangleContextImpl &C, raw_ostream &Out_,
|
||||||
const CXXConstructorDecl *D, CXXCtorType Type)
|
const CXXConstructorDecl *D, CXXCtorType Type)
|
||||||
: Context(C), Out(Out_), Structor(getStructor(D)), StructorType(Type),
|
: Context(C), Out(Out_), Structor(getStructor(D)), StructorType(Type),
|
||||||
TemplateArgStringStorage(TemplateArgStringStorageAlloc),
|
TemplateArgStringStorage(TemplateArgStringStorageAlloc),
|
||||||
PointersAre64Bit(C.getASTContext().getTargetInfo().getPointerWidth(0) ==
|
PointersAre64Bit(C.getASTContext().getTargetInfo().getPointerWidth(
|
||||||
64) {}
|
LangAS::Default) == 64) {}
|
||||||
|
|
||||||
MicrosoftCXXNameMangler(MicrosoftMangleContextImpl &C, raw_ostream &Out_,
|
MicrosoftCXXNameMangler(MicrosoftMangleContextImpl &C, raw_ostream &Out_,
|
||||||
const CXXDestructorDecl *D, CXXDtorType Type)
|
const CXXDestructorDecl *D, CXXDtorType Type)
|
||||||
: Context(C), Out(Out_), Structor(getStructor(D)), StructorType(Type),
|
: Context(C), Out(Out_), Structor(getStructor(D)), StructorType(Type),
|
||||||
TemplateArgStringStorage(TemplateArgStringStorageAlloc),
|
TemplateArgStringStorage(TemplateArgStringStorageAlloc),
|
||||||
PointersAre64Bit(C.getASTContext().getTargetInfo().getPointerWidth(0) ==
|
PointersAre64Bit(C.getASTContext().getTargetInfo().getPointerWidth(
|
||||||
64) {}
|
LangAS::Default) == 64) {}
|
||||||
|
|
||||||
raw_ostream &getStream() const { return Out; }
|
raw_ostream &getStream() const { return Out; }
|
||||||
|
|
||||||
|
@ -776,7 +776,7 @@ void MicrosoftCXXNameMangler::mangleVirtualMemPtrThunk(
|
||||||
const CXXMethodDecl *MD, const MethodVFTableLocation &ML) {
|
const CXXMethodDecl *MD, const MethodVFTableLocation &ML) {
|
||||||
// Get the vftable offset.
|
// Get the vftable offset.
|
||||||
CharUnits PointerWidth = getASTContext().toCharUnitsFromBits(
|
CharUnits PointerWidth = getASTContext().toCharUnitsFromBits(
|
||||||
getASTContext().getTargetInfo().getPointerWidth(0));
|
getASTContext().getTargetInfo().getPointerWidth(LangAS::Default));
|
||||||
uint64_t OffsetInVFTable = ML.Index * PointerWidth.getQuantity();
|
uint64_t OffsetInVFTable = ML.Index * PointerWidth.getQuantity();
|
||||||
|
|
||||||
Out << "?_9";
|
Out << "?_9";
|
||||||
|
|
|
@ -1059,10 +1059,10 @@ void ItaniumRecordLayoutBuilder::LayoutNonVirtualBases(
|
||||||
// primary base, add it in now.
|
// primary base, add it in now.
|
||||||
} else if (RD->isDynamicClass()) {
|
} else if (RD->isDynamicClass()) {
|
||||||
assert(DataSize == 0 && "Vtable pointer must be at offset zero!");
|
assert(DataSize == 0 && "Vtable pointer must be at offset zero!");
|
||||||
CharUnits PtrWidth =
|
CharUnits PtrWidth = Context.toCharUnitsFromBits(
|
||||||
Context.toCharUnitsFromBits(Context.getTargetInfo().getPointerWidth(0));
|
Context.getTargetInfo().getPointerWidth(LangAS::Default));
|
||||||
CharUnits PtrAlign =
|
CharUnits PtrAlign = Context.toCharUnitsFromBits(
|
||||||
Context.toCharUnitsFromBits(Context.getTargetInfo().getPointerAlign(0));
|
Context.getTargetInfo().getPointerAlign(LangAS::Default));
|
||||||
EnsureVTablePointerAlignment(PtrAlign);
|
EnsureVTablePointerAlignment(PtrAlign);
|
||||||
HasOwnVFPtr = true;
|
HasOwnVFPtr = true;
|
||||||
|
|
||||||
|
@ -1911,12 +1911,6 @@ void ItaniumRecordLayoutBuilder::LayoutField(const FieldDecl *D,
|
||||||
|
|
||||||
if (D->getType()->isIncompleteArrayType()) {
|
if (D->getType()->isIncompleteArrayType()) {
|
||||||
setDeclInfo(true /* IsIncompleteArrayType */);
|
setDeclInfo(true /* IsIncompleteArrayType */);
|
||||||
} else if (const ReferenceType *RT = D->getType()->getAs<ReferenceType>()) {
|
|
||||||
unsigned AS = Context.getTargetAddressSpace(RT->getPointeeType());
|
|
||||||
EffectiveFieldSize = FieldSize = Context.toCharUnitsFromBits(
|
|
||||||
Context.getTargetInfo().getPointerWidth(AS));
|
|
||||||
FieldAlign = Context.toCharUnitsFromBits(
|
|
||||||
Context.getTargetInfo().getPointerAlign(AS));
|
|
||||||
} else {
|
} else {
|
||||||
setDeclInfo(false /* IsIncompleteArrayType */);
|
setDeclInfo(false /* IsIncompleteArrayType */);
|
||||||
|
|
||||||
|
@ -2768,7 +2762,8 @@ void MicrosoftRecordLayoutBuilder::initializeLayout(const RecordDecl *RD) {
|
||||||
// than the pointer size.
|
// than the pointer size.
|
||||||
if (const MaxFieldAlignmentAttr *MFAA = RD->getAttr<MaxFieldAlignmentAttr>()){
|
if (const MaxFieldAlignmentAttr *MFAA = RD->getAttr<MaxFieldAlignmentAttr>()){
|
||||||
unsigned PackedAlignment = MFAA->getAlignment();
|
unsigned PackedAlignment = MFAA->getAlignment();
|
||||||
if (PackedAlignment <= Context.getTargetInfo().getPointerWidth(0))
|
if (PackedAlignment <=
|
||||||
|
Context.getTargetInfo().getPointerWidth(LangAS::Default))
|
||||||
MaxFieldAlignment = Context.toCharUnitsFromBits(PackedAlignment);
|
MaxFieldAlignment = Context.toCharUnitsFromBits(PackedAlignment);
|
||||||
}
|
}
|
||||||
// Packed attribute forces max field alignment to be 1.
|
// Packed attribute forces max field alignment to be 1.
|
||||||
|
@ -2793,10 +2788,10 @@ MicrosoftRecordLayoutBuilder::initializeCXXLayout(const CXXRecordDecl *RD) {
|
||||||
SharedVBPtrBase = nullptr;
|
SharedVBPtrBase = nullptr;
|
||||||
// Calculate pointer size and alignment. These are used for vfptr and vbprt
|
// Calculate pointer size and alignment. These are used for vfptr and vbprt
|
||||||
// injection.
|
// injection.
|
||||||
PointerInfo.Size =
|
PointerInfo.Size = Context.toCharUnitsFromBits(
|
||||||
Context.toCharUnitsFromBits(Context.getTargetInfo().getPointerWidth(0));
|
Context.getTargetInfo().getPointerWidth(LangAS::Default));
|
||||||
PointerInfo.Alignment =
|
PointerInfo.Alignment = Context.toCharUnitsFromBits(
|
||||||
Context.toCharUnitsFromBits(Context.getTargetInfo().getPointerAlign(0));
|
Context.getTargetInfo().getPointerAlign(LangAS::Default));
|
||||||
// Respect pragma pack.
|
// Respect pragma pack.
|
||||||
if (!MaxFieldAlignment.isZero())
|
if (!MaxFieldAlignment.isZero())
|
||||||
PointerInfo.Alignment = std::min(PointerInfo.Alignment, MaxFieldAlignment);
|
PointerInfo.Alignment = std::min(PointerInfo.Alignment, MaxFieldAlignment);
|
||||||
|
|
|
@ -670,8 +670,9 @@ CharUnits VCallAndVBaseOffsetBuilder::getCurrentOffsetOffset() const {
|
||||||
// Under the relative ABI, the offset widths are 32-bit ints instead of
|
// Under the relative ABI, the offset widths are 32-bit ints instead of
|
||||||
// pointer widths.
|
// pointer widths.
|
||||||
CharUnits OffsetWidth = Context.toCharUnitsFromBits(
|
CharUnits OffsetWidth = Context.toCharUnitsFromBits(
|
||||||
VTables.isRelativeLayout() ? 32
|
VTables.isRelativeLayout()
|
||||||
: Context.getTargetInfo().getPointerWidth(0));
|
? 32
|
||||||
|
: Context.getTargetInfo().getPointerWidth(LangAS::Default));
|
||||||
CharUnits OffsetOffset = OffsetWidth * OffsetIndex;
|
CharUnits OffsetOffset = OffsetWidth * OffsetIndex;
|
||||||
|
|
||||||
return OffsetOffset;
|
return OffsetOffset;
|
||||||
|
|
|
@ -370,8 +370,8 @@ AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple &Triple,
|
||||||
WavefrontSize = GPUFeatures & llvm::AMDGPU::FEATURE_WAVE32 ? 32 : 64;
|
WavefrontSize = GPUFeatures & llvm::AMDGPU::FEATURE_WAVE32 ? 32 : 64;
|
||||||
AllowAMDGPUUnsafeFPAtomics = Opts.AllowAMDGPUUnsafeFPAtomics;
|
AllowAMDGPUUnsafeFPAtomics = Opts.AllowAMDGPUUnsafeFPAtomics;
|
||||||
|
|
||||||
// Set pointer width and alignment for target address space 0.
|
// Set pointer width and alignment for the generic address space.
|
||||||
PointerWidth = PointerAlign = getPointerWidthV(Generic);
|
PointerWidth = PointerAlign = getPointerWidthV(LangAS::Default);
|
||||||
if (getMaxPointerWidth() == 64) {
|
if (getMaxPointerWidth() == 64) {
|
||||||
LongWidth = LongAlign = 64;
|
LongWidth = LongAlign = 64;
|
||||||
SizeType = UnsignedLong;
|
SizeType = UnsignedLong;
|
||||||
|
|
|
@ -95,17 +95,18 @@ public:
|
||||||
|
|
||||||
void adjust(DiagnosticsEngine &Diags, LangOptions &Opts) override;
|
void adjust(DiagnosticsEngine &Diags, LangOptions &Opts) override;
|
||||||
|
|
||||||
uint64_t getPointerWidthV(unsigned AddrSpace) const override {
|
uint64_t getPointerWidthV(LangAS AS) const override {
|
||||||
if (isR600(getTriple()))
|
if (isR600(getTriple()))
|
||||||
return 32;
|
return 32;
|
||||||
|
unsigned TargetAS = getTargetAddressSpace(AS);
|
||||||
|
|
||||||
if (AddrSpace == Private || AddrSpace == Local)
|
if (TargetAS == Private || TargetAS == Local)
|
||||||
return 32;
|
return 32;
|
||||||
|
|
||||||
return 64;
|
return 64;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t getPointerAlignV(unsigned AddrSpace) const override {
|
uint64_t getPointerAlignV(LangAS AddrSpace) const override {
|
||||||
return getPointerWidthV(AddrSpace);
|
return getPointerWidthV(AddrSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -182,7 +182,7 @@ void MipsTargetInfo::getTargetDefines(const LangOptions &Opts,
|
||||||
if (DisableMadd4)
|
if (DisableMadd4)
|
||||||
Builder.defineMacro("__mips_no_madd4", Twine(1));
|
Builder.defineMacro("__mips_no_madd4", Twine(1));
|
||||||
|
|
||||||
Builder.defineMacro("_MIPS_SZPTR", Twine(getPointerWidth(0)));
|
Builder.defineMacro("_MIPS_SZPTR", Twine(getPointerWidth(LangAS::Default)));
|
||||||
Builder.defineMacro("_MIPS_SZINT", Twine(getIntWidth()));
|
Builder.defineMacro("_MIPS_SZINT", Twine(getIntWidth()));
|
||||||
Builder.defineMacro("_MIPS_SZLONG", Twine(getLongWidth()));
|
Builder.defineMacro("_MIPS_SZLONG", Twine(getLongWidth()));
|
||||||
|
|
||||||
|
@ -229,7 +229,7 @@ unsigned MipsTargetInfo::getUnwindWordWidth() const {
|
||||||
.Case("o32", 32)
|
.Case("o32", 32)
|
||||||
.Case("n32", 64)
|
.Case("n32", 64)
|
||||||
.Case("n64", 64)
|
.Case("n64", 64)
|
||||||
.Default(getPointerWidth(0));
|
.Default(getPointerWidth(LangAS::Default));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MipsTargetInfo::validateTarget(DiagnosticsEngine &Diags) const {
|
bool MipsTargetInfo::validateTarget(DiagnosticsEngine &Diags) const {
|
||||||
|
|
|
@ -97,8 +97,8 @@ NVPTXTargetInfo::NVPTXTargetInfo(const llvm::Triple &Triple,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy properties from host target.
|
// Copy properties from host target.
|
||||||
PointerWidth = HostTarget->getPointerWidth(/* AddrSpace = */ 0);
|
PointerWidth = HostTarget->getPointerWidth(LangAS::Default);
|
||||||
PointerAlign = HostTarget->getPointerAlign(/* AddrSpace = */ 0);
|
PointerAlign = HostTarget->getPointerAlign(LangAS::Default);
|
||||||
BoolWidth = HostTarget->getBoolWidth();
|
BoolWidth = HostTarget->getBoolWidth();
|
||||||
BoolAlign = HostTarget->getBoolAlign();
|
BoolAlign = HostTarget->getBoolAlign();
|
||||||
IntWidth = HostTarget->getIntWidth();
|
IntWidth = HostTarget->getIntWidth();
|
||||||
|
@ -119,7 +119,7 @@ NVPTXTargetInfo::NVPTXTargetInfo(const llvm::Triple &Triple,
|
||||||
HostTarget->getDefaultAlignForAttributeAligned();
|
HostTarget->getDefaultAlignForAttributeAligned();
|
||||||
SizeType = HostTarget->getSizeType();
|
SizeType = HostTarget->getSizeType();
|
||||||
IntMaxType = HostTarget->getIntMaxType();
|
IntMaxType = HostTarget->getIntMaxType();
|
||||||
PtrDiffType = HostTarget->getPtrDiffType(/* AddrSpace = */ 0);
|
PtrDiffType = HostTarget->getPtrDiffType(LangAS::Default);
|
||||||
IntPtrType = HostTarget->getIntPtrType();
|
IntPtrType = HostTarget->getIntPtrType();
|
||||||
WCharType = HostTarget->getWCharType();
|
WCharType = HostTarget->getWCharType();
|
||||||
WIntType = HostTarget->getWIntType();
|
WIntType = HostTarget->getWIntType();
|
||||||
|
|
|
@ -403,15 +403,16 @@ public:
|
||||||
|
|
||||||
void setSupportedOpenCLOpts() override { supportAllOpenCLOpts(); }
|
void setSupportedOpenCLOpts() override { supportAllOpenCLOpts(); }
|
||||||
|
|
||||||
uint64_t getPointerWidthV(unsigned AddrSpace) const override {
|
uint64_t getPointerWidthV(LangAS AS) const override {
|
||||||
if (AddrSpace == ptr32_sptr || AddrSpace == ptr32_uptr)
|
unsigned TargetAddrSpace = getTargetAddressSpace(AS);
|
||||||
|
if (TargetAddrSpace == ptr32_sptr || TargetAddrSpace == ptr32_uptr)
|
||||||
return 32;
|
return 32;
|
||||||
if (AddrSpace == ptr64)
|
if (TargetAddrSpace == ptr64)
|
||||||
return 64;
|
return 64;
|
||||||
return PointerWidth;
|
return PointerWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t getPointerAlignV(unsigned AddrSpace) const override {
|
uint64_t getPointerAlignV(LangAS AddrSpace) const override {
|
||||||
return getPointerWidthV(AddrSpace);
|
return getPointerWidthV(AddrSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -502,12 +502,10 @@ static void initializeForBlockHeader(CodeGenModule &CGM, CGBlockInfo &info,
|
||||||
if (CGM.getLangOpts().OpenCL) {
|
if (CGM.getLangOpts().OpenCL) {
|
||||||
// The header is basically 'struct { int; int; generic void *;
|
// The header is basically 'struct { int; int; generic void *;
|
||||||
// custom_fields; }'. Assert that struct is packed.
|
// custom_fields; }'. Assert that struct is packed.
|
||||||
auto GenericAS =
|
auto GenPtrAlign = CharUnits::fromQuantity(
|
||||||
CGM.getContext().getTargetAddressSpace(LangAS::opencl_generic);
|
CGM.getTarget().getPointerAlign(LangAS::opencl_generic) / 8);
|
||||||
auto GenPtrAlign =
|
auto GenPtrSize = CharUnits::fromQuantity(
|
||||||
CharUnits::fromQuantity(CGM.getTarget().getPointerAlign(GenericAS) / 8);
|
CGM.getTarget().getPointerWidth(LangAS::opencl_generic) / 8);
|
||||||
auto GenPtrSize =
|
|
||||||
CharUnits::fromQuantity(CGM.getTarget().getPointerWidth(GenericAS) / 8);
|
|
||||||
assert(CGM.getIntSize() <= GenPtrSize);
|
assert(CGM.getIntSize() <= GenPtrSize);
|
||||||
assert(CGM.getIntAlign() <= GenPtrAlign);
|
assert(CGM.getIntAlign() <= GenPtrAlign);
|
||||||
assert((2 * CGM.getIntSize()).isMultipleOf(GenPtrAlign));
|
assert((2 * CGM.getIntSize()).isMultipleOf(GenPtrAlign));
|
||||||
|
@ -806,9 +804,7 @@ llvm::Value *CodeGenFunction::EmitBlockLiteral(const CGBlockInfo &blockInfo) {
|
||||||
IsOpenCL ? CGM.getOpenCLRuntime().getGenericVoidPointerType() : VoidPtrTy;
|
IsOpenCL ? CGM.getOpenCLRuntime().getGenericVoidPointerType() : VoidPtrTy;
|
||||||
LangAS GenVoidPtrAddr = IsOpenCL ? LangAS::opencl_generic : LangAS::Default;
|
LangAS GenVoidPtrAddr = IsOpenCL ? LangAS::opencl_generic : LangAS::Default;
|
||||||
auto GenVoidPtrSize = CharUnits::fromQuantity(
|
auto GenVoidPtrSize = CharUnits::fromQuantity(
|
||||||
CGM.getTarget().getPointerWidth(
|
CGM.getTarget().getPointerWidth(GenVoidPtrAddr) / 8);
|
||||||
CGM.getContext().getTargetAddressSpace(GenVoidPtrAddr)) /
|
|
||||||
8);
|
|
||||||
// Using the computed layout, generate the actual block function.
|
// Using the computed layout, generate the actual block function.
|
||||||
bool isLambdaConv = blockInfo.getBlockDecl()->isConversionFromLambda();
|
bool isLambdaConv = blockInfo.getBlockDecl()->isConversionFromLambda();
|
||||||
CodeGenFunction BlockCGF{CGM, true};
|
CodeGenFunction BlockCGF{CGM, true};
|
||||||
|
|
|
@ -4458,7 +4458,7 @@ QualType CodeGenFunction::getVarArgType(const Expr *Arg) {
|
||||||
|
|
||||||
if (Arg->getType()->isIntegerType() &&
|
if (Arg->getType()->isIntegerType() &&
|
||||||
getContext().getTypeSize(Arg->getType()) <
|
getContext().getTypeSize(Arg->getType()) <
|
||||||
getContext().getTargetInfo().getPointerWidth(0) &&
|
getContext().getTargetInfo().getPointerWidth(LangAS::Default) &&
|
||||||
Arg->isNullPointerConstant(getContext(),
|
Arg->isNullPointerConstant(getContext(),
|
||||||
Expr::NPC_ValueDependentIsNotNull)) {
|
Expr::NPC_ValueDependentIsNotNull)) {
|
||||||
return getContext().getIntPtrType();
|
return getContext().getIntPtrType();
|
||||||
|
|
|
@ -1145,13 +1145,11 @@ llvm::DIType *CGDebugInfo::CreatePointerLikeType(llvm::dwarf::Tag Tag,
|
||||||
QualType PointeeTy,
|
QualType PointeeTy,
|
||||||
llvm::DIFile *Unit) {
|
llvm::DIFile *Unit) {
|
||||||
// Bit size, align and offset of the type.
|
// Bit size, align and offset of the type.
|
||||||
// Size is always the size of a pointer. We can't use getTypeSize here
|
// Size is always the size of a pointer.
|
||||||
// because that does not return the correct value for references.
|
uint64_t Size = CGM.getContext().getTypeSize(Ty);
|
||||||
unsigned AddressSpace = CGM.getContext().getTargetAddressSpace(PointeeTy);
|
|
||||||
uint64_t Size = CGM.getTarget().getPointerWidth(AddressSpace);
|
|
||||||
auto Align = getTypeAlignIfRequired(Ty, CGM.getContext());
|
auto Align = getTypeAlignIfRequired(Ty, CGM.getContext());
|
||||||
Optional<unsigned> DWARFAddressSpace =
|
Optional<unsigned> DWARFAddressSpace = CGM.getTarget().getDWARFAddressSpace(
|
||||||
CGM.getTarget().getDWARFAddressSpace(AddressSpace);
|
CGM.getContext().getTargetAddressSpace(PointeeTy));
|
||||||
|
|
||||||
SmallVector<llvm::Metadata *, 4> Annots;
|
SmallVector<llvm::Metadata *, 4> Annots;
|
||||||
auto *BTFAttrTy = dyn_cast<BTFTagAttributedType>(PointeeTy);
|
auto *BTFAttrTy = dyn_cast<BTFTagAttributedType>(PointeeTy);
|
||||||
|
@ -1703,11 +1701,10 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType(
|
||||||
if (isa<ClassTemplateSpecializationDecl>(RD)) {
|
if (isa<ClassTemplateSpecializationDecl>(RD)) {
|
||||||
// Create pointer type directly in this case.
|
// Create pointer type directly in this case.
|
||||||
const PointerType *ThisPtrTy = cast<PointerType>(ThisPtr);
|
const PointerType *ThisPtrTy = cast<PointerType>(ThisPtr);
|
||||||
QualType PointeeTy = ThisPtrTy->getPointeeType();
|
uint64_t Size = CGM.getContext().getTypeSize(ThisPtrTy);
|
||||||
unsigned AS = CGM.getContext().getTargetAddressSpace(PointeeTy);
|
|
||||||
uint64_t Size = CGM.getTarget().getPointerWidth(AS);
|
|
||||||
auto Align = getTypeAlignIfRequired(ThisPtrTy, CGM.getContext());
|
auto Align = getTypeAlignIfRequired(ThisPtrTy, CGM.getContext());
|
||||||
llvm::DIType *PointeeType = getOrCreateType(PointeeTy, Unit);
|
llvm::DIType *PointeeType =
|
||||||
|
getOrCreateType(ThisPtrTy->getPointeeType(), Unit);
|
||||||
llvm::DIType *ThisPtrType =
|
llvm::DIType *ThisPtrType =
|
||||||
DBuilder.createPointerType(PointeeType, Size, Align);
|
DBuilder.createPointerType(PointeeType, Size, Align);
|
||||||
TypeCache[ThisPtr.getAsOpaquePtr()].reset(ThisPtrType);
|
TypeCache[ThisPtr.getAsOpaquePtr()].reset(ThisPtrType);
|
||||||
|
@ -4383,7 +4380,7 @@ CGDebugInfo::EmitTypeForVarWithBlocksAttr(const VarDecl *VD,
|
||||||
|
|
||||||
CharUnits Align = CGM.getContext().getDeclAlign(VD);
|
CharUnits Align = CGM.getContext().getDeclAlign(VD);
|
||||||
if (Align > CGM.getContext().toCharUnitsFromBits(
|
if (Align > CGM.getContext().toCharUnitsFromBits(
|
||||||
CGM.getTarget().getPointerAlign(0))) {
|
CGM.getTarget().getPointerAlign(LangAS::Default))) {
|
||||||
CharUnits FieldOffsetInBytes =
|
CharUnits FieldOffsetInBytes =
|
||||||
CGM.getContext().toCharUnitsFromBits(FieldOffset);
|
CGM.getContext().toCharUnitsFromBits(FieldOffset);
|
||||||
CharUnits AlignedOffsetInBytes = FieldOffsetInBytes.alignTo(Align);
|
CharUnits AlignedOffsetInBytes = FieldOffsetInBytes.alignTo(Align);
|
||||||
|
@ -4483,7 +4480,7 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const VarDecl *VD,
|
||||||
Expr.push_back(llvm::dwarf::DW_OP_plus_uconst);
|
Expr.push_back(llvm::dwarf::DW_OP_plus_uconst);
|
||||||
// offset of __forwarding field
|
// offset of __forwarding field
|
||||||
offset = CGM.getContext().toCharUnitsFromBits(
|
offset = CGM.getContext().toCharUnitsFromBits(
|
||||||
CGM.getTarget().getPointerWidth(0));
|
CGM.getTarget().getPointerWidth(LangAS::Default));
|
||||||
Expr.push_back(offset.getQuantity());
|
Expr.push_back(offset.getQuantity());
|
||||||
Expr.push_back(llvm::dwarf::DW_OP_deref);
|
Expr.push_back(llvm::dwarf::DW_OP_deref);
|
||||||
Expr.push_back(llvm::dwarf::DW_OP_plus_uconst);
|
Expr.push_back(llvm::dwarf::DW_OP_plus_uconst);
|
||||||
|
|
|
@ -1926,7 +1926,7 @@ static CharUnits GetNumNonZeroBytesInInit(const Expr *E, CodeGenFunction &CGF) {
|
||||||
// Reference values are always non-null and have the width of a pointer.
|
// Reference values are always non-null and have the width of a pointer.
|
||||||
if (Field->getType()->isReferenceType())
|
if (Field->getType()->isReferenceType())
|
||||||
NumNonZeroBytes += CGF.getContext().toCharUnitsFromBits(
|
NumNonZeroBytes += CGF.getContext().toCharUnitsFromBits(
|
||||||
CGF.getTarget().getPointerWidth(0));
|
CGF.getTarget().getPointerWidth(LangAS::Default));
|
||||||
else
|
else
|
||||||
NumNonZeroBytes += GetNumNonZeroBytesInInit(E, CGF);
|
NumNonZeroBytes += GetNumNonZeroBytesInInit(E, CGF);
|
||||||
}
|
}
|
||||||
|
|
|
@ -985,7 +985,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
|
||||||
|
|
||||||
auto LiteralLength = SL->getLength();
|
auto LiteralLength = SL->getLength();
|
||||||
|
|
||||||
if ((CGM.getTarget().getPointerWidth(0) == 64) &&
|
if ((CGM.getTarget().getPointerWidth(LangAS::Default) == 64) &&
|
||||||
(LiteralLength < 9) && !isNonASCII) {
|
(LiteralLength < 9) && !isNonASCII) {
|
||||||
// Tiny strings are only used on 64-bit platforms. They store 8 7-bit
|
// Tiny strings are only used on 64-bit platforms. They store 8 7-bit
|
||||||
// ASCII characters in the high 56 bits, followed by a 4-bit length and a
|
// ASCII characters in the high 56 bits, followed by a 4-bit length and a
|
||||||
|
|
|
@ -2407,8 +2407,8 @@ void IvarLayoutBuilder::visitBlock(const CGBlockInfo &blockInfo) {
|
||||||
Qualifiers::GC GCAttr = GetGCAttrTypeForType(CGM.getContext(), type);
|
Qualifiers::GC GCAttr = GetGCAttrTypeForType(CGM.getContext(), type);
|
||||||
|
|
||||||
if (GCAttr == Qualifiers::Strong) {
|
if (GCAttr == Qualifiers::Strong) {
|
||||||
assert(CGM.getContext().getTypeSize(type)
|
assert(CGM.getContext().getTypeSize(type) ==
|
||||||
== CGM.getTarget().getPointerWidth(0));
|
CGM.getTarget().getPointerWidth(LangAS::Default));
|
||||||
IvarsInfo.push_back(IvarInfo(fieldOffset, /*size in words*/ 1));
|
IvarsInfo.push_back(IvarInfo(fieldOffset, /*size in words*/ 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2701,7 +2701,7 @@ llvm::Constant *CGObjCCommonMac::getBitmapBlockLayout(bool ComputeByrefLayout) {
|
||||||
llvm::Constant *nullPtr = llvm::Constant::getNullValue(CGM.Int8PtrTy);
|
llvm::Constant *nullPtr = llvm::Constant::getNullValue(CGM.Int8PtrTy);
|
||||||
if (RunSkipBlockVars.empty())
|
if (RunSkipBlockVars.empty())
|
||||||
return nullPtr;
|
return nullPtr;
|
||||||
unsigned WordSizeInBits = CGM.getTarget().getPointerWidth(0);
|
unsigned WordSizeInBits = CGM.getTarget().getPointerWidth(LangAS::Default);
|
||||||
unsigned ByteSizeInBits = CGM.getTarget().getCharWidth();
|
unsigned ByteSizeInBits = CGM.getTarget().getCharWidth();
|
||||||
unsigned WordSizeInBytes = WordSizeInBits/ByteSizeInBits;
|
unsigned WordSizeInBytes = WordSizeInBits/ByteSizeInBits;
|
||||||
|
|
||||||
|
@ -2887,7 +2887,7 @@ void CGObjCCommonMac::fillRunSkipBlockVars(CodeGenModule &CGM,
|
||||||
RunSkipBlockVars.clear();
|
RunSkipBlockVars.clear();
|
||||||
bool hasUnion = false;
|
bool hasUnion = false;
|
||||||
|
|
||||||
unsigned WordSizeInBits = CGM.getTarget().getPointerWidth(0);
|
unsigned WordSizeInBits = CGM.getTarget().getPointerWidth(LangAS::Default);
|
||||||
unsigned ByteSizeInBits = CGM.getTarget().getCharWidth();
|
unsigned ByteSizeInBits = CGM.getTarget().getCharWidth();
|
||||||
unsigned WordSizeInBytes = WordSizeInBits/ByteSizeInBits;
|
unsigned WordSizeInBytes = WordSizeInBits/ByteSizeInBits;
|
||||||
|
|
||||||
|
|
|
@ -1281,8 +1281,8 @@ void CodeGenModule::EmitVTableTypeMetadata(const CXXRecordDecl *RD,
|
||||||
if (!getCodeGenOpts().LTOUnit)
|
if (!getCodeGenOpts().LTOUnit)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CharUnits PointerWidth =
|
CharUnits PointerWidth = Context.toCharUnitsFromBits(
|
||||||
Context.toCharUnitsFromBits(Context.getTargetInfo().getPointerWidth(0));
|
Context.getTargetInfo().getPointerWidth(LangAS::Default));
|
||||||
|
|
||||||
typedef std::pair<const CXXRecordDecl *, unsigned> AddressPoint;
|
typedef std::pair<const CXXRecordDecl *, unsigned> AddressPoint;
|
||||||
std::vector<AddressPoint> AddressPoints;
|
std::vector<AddressPoint> AddressPoints;
|
||||||
|
|
|
@ -123,9 +123,10 @@ CodeGenModule::CodeGenModule(ASTContext &C,
|
||||||
BFloatTy = llvm::Type::getBFloatTy(LLVMContext);
|
BFloatTy = llvm::Type::getBFloatTy(LLVMContext);
|
||||||
FloatTy = llvm::Type::getFloatTy(LLVMContext);
|
FloatTy = llvm::Type::getFloatTy(LLVMContext);
|
||||||
DoubleTy = llvm::Type::getDoubleTy(LLVMContext);
|
DoubleTy = llvm::Type::getDoubleTy(LLVMContext);
|
||||||
PointerWidthInBits = C.getTargetInfo().getPointerWidth(0);
|
PointerWidthInBits = C.getTargetInfo().getPointerWidth(LangAS::Default);
|
||||||
PointerAlignInBytes =
|
PointerAlignInBytes =
|
||||||
C.toCharUnitsFromBits(C.getTargetInfo().getPointerAlign(0)).getQuantity();
|
C.toCharUnitsFromBits(C.getTargetInfo().getPointerAlign(LangAS::Default))
|
||||||
|
.getQuantity();
|
||||||
SizeSizeInBytes =
|
SizeSizeInBytes =
|
||||||
C.toCharUnitsFromBits(C.getTargetInfo().getMaxPointerWidth()).getQuantity();
|
C.toCharUnitsFromBits(C.getTargetInfo().getMaxPointerWidth()).getQuantity();
|
||||||
IntAlignInBytes =
|
IntAlignInBytes =
|
||||||
|
|
|
@ -1002,7 +1002,7 @@ llvm::Constant *ItaniumCXXABI::BuildMemberPointer(const CXXMethodDecl *MD,
|
||||||
} else {
|
} else {
|
||||||
const ASTContext &Context = getContext();
|
const ASTContext &Context = getContext();
|
||||||
CharUnits PointerWidth = Context.toCharUnitsFromBits(
|
CharUnits PointerWidth = Context.toCharUnitsFromBits(
|
||||||
Context.getTargetInfo().getPointerWidth(0));
|
Context.getTargetInfo().getPointerWidth(LangAS::Default));
|
||||||
VTableOffset = Index * PointerWidth.getQuantity();
|
VTableOffset = Index * PointerWidth.getQuantity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1879,7 +1879,7 @@ llvm::GlobalVariable *ItaniumCXXABI::getAddrOfVTable(const CXXRecordDecl *RD,
|
||||||
// values are read.
|
// values are read.
|
||||||
unsigned PAlign = CGM.getItaniumVTableContext().isRelativeLayout()
|
unsigned PAlign = CGM.getItaniumVTableContext().isRelativeLayout()
|
||||||
? 32
|
? 32
|
||||||
: CGM.getTarget().getPointerAlign(0);
|
: CGM.getTarget().getPointerAlign(LangAS::Default);
|
||||||
|
|
||||||
VTable = CGM.CreateOrReplaceCXXRuntimeVariable(
|
VTable = CGM.CreateOrReplaceCXXRuntimeVariable(
|
||||||
Name, VTableType, llvm::GlobalValue::ExternalLinkage,
|
Name, VTableType, llvm::GlobalValue::ExternalLinkage,
|
||||||
|
@ -1924,7 +1924,9 @@ CGCallee ItaniumCXXABI::getVirtualFunctionPointer(CodeGenFunction &CGF,
|
||||||
if (CGF.ShouldEmitVTableTypeCheckedLoad(MethodDecl->getParent())) {
|
if (CGF.ShouldEmitVTableTypeCheckedLoad(MethodDecl->getParent())) {
|
||||||
VFunc = CGF.EmitVTableTypeCheckedLoad(
|
VFunc = CGF.EmitVTableTypeCheckedLoad(
|
||||||
MethodDecl->getParent(), VTable, TyPtr,
|
MethodDecl->getParent(), VTable, TyPtr,
|
||||||
VTableIndex * CGM.getContext().getTargetInfo().getPointerWidth(0) / 8);
|
VTableIndex *
|
||||||
|
CGM.getContext().getTargetInfo().getPointerWidth(LangAS::Default) /
|
||||||
|
8);
|
||||||
} else {
|
} else {
|
||||||
CGF.EmitTypeMetadataCodeForVCall(MethodDecl->getParent(), VTable, Loc);
|
CGF.EmitTypeMetadataCodeForVCall(MethodDecl->getParent(), VTable, Loc);
|
||||||
|
|
||||||
|
@ -3877,8 +3879,8 @@ llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(
|
||||||
if (CGM.supportsCOMDAT() && GV->isWeakForLinker())
|
if (CGM.supportsCOMDAT() && GV->isWeakForLinker())
|
||||||
GV->setComdat(M.getOrInsertComdat(GV->getName()));
|
GV->setComdat(M.getOrInsertComdat(GV->getName()));
|
||||||
|
|
||||||
CharUnits Align =
|
CharUnits Align = CGM.getContext().toCharUnitsFromBits(
|
||||||
CGM.getContext().toCharUnitsFromBits(CGM.getTarget().getPointerAlign(0));
|
CGM.getTarget().getPointerAlign(LangAS::Default));
|
||||||
GV->setAlignment(Align.getAsAlign());
|
GV->setAlignment(Align.getAsAlign());
|
||||||
|
|
||||||
// The Itanium ABI specifies that type_info objects must be globally
|
// The Itanium ABI specifies that type_info objects must be globally
|
||||||
|
@ -4056,7 +4058,8 @@ void ItaniumRTTIBuilder::BuildVMIClassTypeInfo(const CXXRecordDecl *RD) {
|
||||||
// LLP64 platforms.
|
// LLP64 platforms.
|
||||||
QualType OffsetFlagsTy = CGM.getContext().LongTy;
|
QualType OffsetFlagsTy = CGM.getContext().LongTy;
|
||||||
const TargetInfo &TI = CGM.getContext().getTargetInfo();
|
const TargetInfo &TI = CGM.getContext().getTargetInfo();
|
||||||
if (TI.getTriple().isOSCygMing() && TI.getPointerWidth(0) > TI.getLongWidth())
|
if (TI.getTriple().isOSCygMing() &&
|
||||||
|
TI.getPointerWidth(LangAS::Default) > TI.getLongWidth())
|
||||||
OffsetFlagsTy = CGM.getContext().LongLongTy;
|
OffsetFlagsTy = CGM.getContext().LongLongTy;
|
||||||
llvm::Type *OffsetFlagsLTy =
|
llvm::Type *OffsetFlagsLTy =
|
||||||
CGM.getTypes().ConvertType(OffsetFlagsTy);
|
CGM.getTypes().ConvertType(OffsetFlagsTy);
|
||||||
|
|
|
@ -458,7 +458,7 @@ public:
|
||||||
friend struct MSRTTIBuilder;
|
friend struct MSRTTIBuilder;
|
||||||
|
|
||||||
bool isImageRelative() const {
|
bool isImageRelative() const {
|
||||||
return CGM.getTarget().getPointerWidth(/*AddrSpace=*/0) == 64;
|
return CGM.getTarget().getPointerWidth(LangAS::Default) == 64;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5 routines for constructing the llvm types for MS RTTI structs.
|
// 5 routines for constructing the llvm types for MS RTTI structs.
|
||||||
|
@ -1671,7 +1671,7 @@ void MicrosoftCXXABI::emitVTableTypeMetadata(const VPtrInfo &Info,
|
||||||
CharUnits AddressPoint =
|
CharUnits AddressPoint =
|
||||||
getContext().getLangOpts().RTTIData
|
getContext().getLangOpts().RTTIData
|
||||||
? getContext().toCharUnitsFromBits(
|
? getContext().toCharUnitsFromBits(
|
||||||
getContext().getTargetInfo().getPointerWidth(0))
|
getContext().getTargetInfo().getPointerWidth(LangAS::Default))
|
||||||
: CharUnits::Zero();
|
: CharUnits::Zero();
|
||||||
|
|
||||||
if (Info.PathToIntroducingObject.empty()) {
|
if (Info.PathToIntroducingObject.empty()) {
|
||||||
|
@ -1944,7 +1944,9 @@ CGCallee MicrosoftCXXABI::getVirtualFunctionPointer(CodeGenFunction &CGF,
|
||||||
if (CGF.ShouldEmitVTableTypeCheckedLoad(MethodDecl->getParent())) {
|
if (CGF.ShouldEmitVTableTypeCheckedLoad(MethodDecl->getParent())) {
|
||||||
VFunc = CGF.EmitVTableTypeCheckedLoad(
|
VFunc = CGF.EmitVTableTypeCheckedLoad(
|
||||||
getObjectWithVPtr(), VTable, Ty,
|
getObjectWithVPtr(), VTable, Ty,
|
||||||
ML.Index * CGM.getContext().getTargetInfo().getPointerWidth(0) / 8);
|
ML.Index *
|
||||||
|
CGM.getContext().getTargetInfo().getPointerWidth(LangAS::Default) /
|
||||||
|
8);
|
||||||
} else {
|
} else {
|
||||||
if (CGM.getCodeGenOpts().PrepareForLTO)
|
if (CGM.getCodeGenOpts().PrepareForLTO)
|
||||||
CGF.EmitTypeMetadataCodeForVCall(getObjectWithVPtr(), VTable, Loc);
|
CGF.EmitTypeMetadataCodeForVCall(getObjectWithVPtr(), VTable, Loc);
|
||||||
|
|
|
@ -43,8 +43,8 @@ llvm::Constant *clang::CodeGen::initializationPatternFor(CodeGenModule &CGM,
|
||||||
}
|
}
|
||||||
if (Ty->isPtrOrPtrVectorTy()) {
|
if (Ty->isPtrOrPtrVectorTy()) {
|
||||||
auto *PtrTy = cast<llvm::PointerType>(Ty->getScalarType());
|
auto *PtrTy = cast<llvm::PointerType>(Ty->getScalarType());
|
||||||
unsigned PtrWidth = CGM.getContext().getTargetInfo().getPointerWidth(
|
unsigned PtrWidth =
|
||||||
PtrTy->getAddressSpace());
|
CGM.getDataLayout().getPointerSizeInBits(PtrTy->getAddressSpace());
|
||||||
if (PtrWidth > 64)
|
if (PtrWidth > 64)
|
||||||
llvm_unreachable("pattern initialization of unsupported pointer width");
|
llvm_unreachable("pattern initialization of unsupported pointer width");
|
||||||
llvm::Type *IntTy = llvm::IntegerType::get(CGM.getLLVMContext(), PtrWidth);
|
llvm::Type *IntTy = llvm::IntegerType::get(CGM.getLLVMContext(), PtrWidth);
|
||||||
|
|
|
@ -652,7 +652,7 @@ bool swiftcall::shouldPassIndirectly(CodeGenModule &CGM,
|
||||||
CharUnits swiftcall::getMaximumVoluntaryIntegerSize(CodeGenModule &CGM) {
|
CharUnits swiftcall::getMaximumVoluntaryIntegerSize(CodeGenModule &CGM) {
|
||||||
// Currently always the size of an ordinary pointer.
|
// Currently always the size of an ordinary pointer.
|
||||||
return CGM.getContext().toCharUnitsFromBits(
|
return CGM.getContext().toCharUnitsFromBits(
|
||||||
CGM.getContext().getTargetInfo().getPointerWidth(0));
|
CGM.getContext().getTargetInfo().getPointerWidth(LangAS::Default));
|
||||||
}
|
}
|
||||||
|
|
||||||
CharUnits swiftcall::getNaturalAlignment(CodeGenModule &CGM, llvm::Type *type) {
|
CharUnits swiftcall::getNaturalAlignment(CodeGenModule &CGM, llvm::Type *type) {
|
||||||
|
|
|
@ -141,7 +141,7 @@ static bool occupiesMoreThan(CodeGenTypes &cgt,
|
||||||
if (type->isPointerTy()) {
|
if (type->isPointerTy()) {
|
||||||
intCount++;
|
intCount++;
|
||||||
} else if (auto intTy = dyn_cast<llvm::IntegerType>(type)) {
|
} else if (auto intTy = dyn_cast<llvm::IntegerType>(type)) {
|
||||||
auto ptrWidth = cgt.getTarget().getPointerWidth(0);
|
auto ptrWidth = cgt.getTarget().getPointerWidth(LangAS::Default);
|
||||||
intCount += (intTy->getBitWidth() + ptrWidth - 1) / ptrWidth;
|
intCount += (intTy->getBitWidth() + ptrWidth - 1) / ptrWidth;
|
||||||
} else {
|
} else {
|
||||||
assert(type->isVectorTy() || type->isFloatingPointTy());
|
assert(type->isVectorTy() || type->isFloatingPointTy());
|
||||||
|
@ -5831,8 +5831,9 @@ AArch64ABIInfo::classifyArgumentType(QualType Ty, bool IsVariadic,
|
||||||
Alignment = getContext().getTypeUnadjustedAlign(Ty);
|
Alignment = getContext().getTypeUnadjustedAlign(Ty);
|
||||||
Alignment = Alignment < 128 ? 64 : 128;
|
Alignment = Alignment < 128 ? 64 : 128;
|
||||||
} else {
|
} else {
|
||||||
Alignment = std::max(getContext().getTypeAlign(Ty),
|
Alignment =
|
||||||
(unsigned)getTarget().getPointerWidth(0));
|
std::max(getContext().getTypeAlign(Ty),
|
||||||
|
(unsigned)getTarget().getPointerWidth(LangAS::Default));
|
||||||
}
|
}
|
||||||
Size = llvm::alignTo(Size, Alignment);
|
Size = llvm::alignTo(Size, Alignment);
|
||||||
|
|
||||||
|
@ -6247,7 +6248,7 @@ Address AArch64ABIInfo::EmitDarwinVAArg(Address VAListAddr, QualType Ty,
|
||||||
if (!isAggregateTypeForABI(Ty) && !isIllegalVectorType(Ty))
|
if (!isAggregateTypeForABI(Ty) && !isIllegalVectorType(Ty))
|
||||||
return EmitVAArgInstr(CGF, VAListAddr, Ty, ABIArgInfo::getDirect());
|
return EmitVAArgInstr(CGF, VAListAddr, Ty, ABIArgInfo::getDirect());
|
||||||
|
|
||||||
uint64_t PointerSize = getTarget().getPointerWidth(0) / 8;
|
uint64_t PointerSize = getTarget().getPointerWidth(LangAS::Default) / 8;
|
||||||
CharUnits SlotSize = CharUnits::fromQuantity(PointerSize);
|
CharUnits SlotSize = CharUnits::fromQuantity(PointerSize);
|
||||||
|
|
||||||
// Empty records are ignored for parameter passing purposes.
|
// Empty records are ignored for parameter passing purposes.
|
||||||
|
@ -8199,7 +8200,7 @@ Address MipsABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
|
||||||
// Integer arguments are promoted to 32-bit on O32 and 64-bit on N32/N64.
|
// Integer arguments are promoted to 32-bit on O32 and 64-bit on N32/N64.
|
||||||
// Pointers are also promoted in the same way but this only matters for N32.
|
// Pointers are also promoted in the same way but this only matters for N32.
|
||||||
unsigned SlotSizeInBits = IsO32 ? 32 : 64;
|
unsigned SlotSizeInBits = IsO32 ? 32 : 64;
|
||||||
unsigned PtrWidth = getTarget().getPointerWidth(0);
|
unsigned PtrWidth = getTarget().getPointerWidth(LangAS::Default);
|
||||||
bool DidPromote = false;
|
bool DidPromote = false;
|
||||||
if ((Ty->isIntegerType() &&
|
if ((Ty->isIntegerType() &&
|
||||||
getContext().getIntWidth(Ty) < SlotSizeInBits) ||
|
getContext().getIntWidth(Ty) < SlotSizeInBits) ||
|
||||||
|
@ -12201,7 +12202,7 @@ const TargetCodeGenInfo &CodeGenModule::getTargetCodeGenInfo() {
|
||||||
case llvm::Triple::riscv32:
|
case llvm::Triple::riscv32:
|
||||||
case llvm::Triple::riscv64: {
|
case llvm::Triple::riscv64: {
|
||||||
StringRef ABIStr = getTarget().getABI();
|
StringRef ABIStr = getTarget().getABI();
|
||||||
unsigned XLen = getTarget().getPointerWidth(0);
|
unsigned XLen = getTarget().getPointerWidth(LangAS::Default);
|
||||||
unsigned ABIFLen = 0;
|
unsigned ABIFLen = 0;
|
||||||
if (ABIStr.endswith("f"))
|
if (ABIStr.endswith("f"))
|
||||||
ABIFLen = 32;
|
ABIFLen = 32;
|
||||||
|
@ -12296,7 +12297,7 @@ const TargetCodeGenInfo &CodeGenModule::getTargetCodeGenInfo() {
|
||||||
else if (ABIStr.endswith("d"))
|
else if (ABIStr.endswith("d"))
|
||||||
ABIFRLen = 64;
|
ABIFRLen = 64;
|
||||||
return SetCGInfo(new LoongArchTargetCodeGenInfo(
|
return SetCGInfo(new LoongArchTargetCodeGenInfo(
|
||||||
Types, getTarget().getPointerWidth(0), ABIFRLen));
|
Types, getTarget().getPointerWidth(LangAS::Default), ABIFRLen));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -948,14 +948,14 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
|
||||||
Builder.defineMacro("__LITTLE_ENDIAN__");
|
Builder.defineMacro("__LITTLE_ENDIAN__");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TI.getPointerWidth(0) == 64 && TI.getLongWidth() == 64
|
if (TI.getPointerWidth(LangAS::Default) == 64 && TI.getLongWidth() == 64 &&
|
||||||
&& TI.getIntWidth() == 32) {
|
TI.getIntWidth() == 32) {
|
||||||
Builder.defineMacro("_LP64");
|
Builder.defineMacro("_LP64");
|
||||||
Builder.defineMacro("__LP64__");
|
Builder.defineMacro("__LP64__");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TI.getPointerWidth(0) == 32 && TI.getLongWidth() == 32
|
if (TI.getPointerWidth(LangAS::Default) == 32 && TI.getLongWidth() == 32 &&
|
||||||
&& TI.getIntWidth() == 32) {
|
TI.getIntWidth() == 32) {
|
||||||
Builder.defineMacro("_ILP32");
|
Builder.defineMacro("_ILP32");
|
||||||
Builder.defineMacro("__ILP32__");
|
Builder.defineMacro("__ILP32__");
|
||||||
}
|
}
|
||||||
|
@ -988,7 +988,8 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
|
||||||
DefineTypeSizeAndWidth("__SIZE", TI.getSizeType(), TI, Builder);
|
DefineTypeSizeAndWidth("__SIZE", TI.getSizeType(), TI, Builder);
|
||||||
|
|
||||||
DefineTypeSizeAndWidth("__UINTMAX", TI.getUIntMaxType(), TI, Builder);
|
DefineTypeSizeAndWidth("__UINTMAX", TI.getUIntMaxType(), TI, Builder);
|
||||||
DefineTypeSizeAndWidth("__PTRDIFF", TI.getPtrDiffType(0), TI, Builder);
|
DefineTypeSizeAndWidth("__PTRDIFF", TI.getPtrDiffType(LangAS::Default), TI,
|
||||||
|
Builder);
|
||||||
DefineTypeSizeAndWidth("__INTPTR", TI.getIntPtrType(), TI, Builder);
|
DefineTypeSizeAndWidth("__INTPTR", TI.getIntPtrType(), TI, Builder);
|
||||||
DefineTypeSizeAndWidth("__UINTPTR", TI.getUIntPtrType(), TI, Builder);
|
DefineTypeSizeAndWidth("__UINTPTR", TI.getUIntPtrType(), TI, Builder);
|
||||||
|
|
||||||
|
@ -998,10 +999,12 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
|
||||||
DefineTypeSizeof("__SIZEOF_LONG__", TI.getLongWidth(), TI, Builder);
|
DefineTypeSizeof("__SIZEOF_LONG__", TI.getLongWidth(), TI, Builder);
|
||||||
DefineTypeSizeof("__SIZEOF_LONG_DOUBLE__",TI.getLongDoubleWidth(),TI,Builder);
|
DefineTypeSizeof("__SIZEOF_LONG_DOUBLE__",TI.getLongDoubleWidth(),TI,Builder);
|
||||||
DefineTypeSizeof("__SIZEOF_LONG_LONG__", TI.getLongLongWidth(), TI, Builder);
|
DefineTypeSizeof("__SIZEOF_LONG_LONG__", TI.getLongLongWidth(), TI, Builder);
|
||||||
DefineTypeSizeof("__SIZEOF_POINTER__", TI.getPointerWidth(0), TI, Builder);
|
DefineTypeSizeof("__SIZEOF_POINTER__", TI.getPointerWidth(LangAS::Default),
|
||||||
|
TI, Builder);
|
||||||
DefineTypeSizeof("__SIZEOF_SHORT__", TI.getShortWidth(), TI, Builder);
|
DefineTypeSizeof("__SIZEOF_SHORT__", TI.getShortWidth(), TI, Builder);
|
||||||
DefineTypeSizeof("__SIZEOF_PTRDIFF_T__",
|
DefineTypeSizeof("__SIZEOF_PTRDIFF_T__",
|
||||||
TI.getTypeWidth(TI.getPtrDiffType(0)), TI, Builder);
|
TI.getTypeWidth(TI.getPtrDiffType(LangAS::Default)), TI,
|
||||||
|
Builder);
|
||||||
DefineTypeSizeof("__SIZEOF_SIZE_T__",
|
DefineTypeSizeof("__SIZEOF_SIZE_T__",
|
||||||
TI.getTypeWidth(TI.getSizeType()), TI, Builder);
|
TI.getTypeWidth(TI.getSizeType()), TI, Builder);
|
||||||
DefineTypeSizeof("__SIZEOF_WCHAR_T__",
|
DefineTypeSizeof("__SIZEOF_WCHAR_T__",
|
||||||
|
@ -1019,8 +1022,8 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
|
||||||
DefineFmt("__UINTMAX", TI.getUIntMaxType(), TI, Builder);
|
DefineFmt("__UINTMAX", TI.getUIntMaxType(), TI, Builder);
|
||||||
Builder.defineMacro("__UINTMAX_C_SUFFIX__",
|
Builder.defineMacro("__UINTMAX_C_SUFFIX__",
|
||||||
TI.getTypeConstantSuffix(TI.getUIntMaxType()));
|
TI.getTypeConstantSuffix(TI.getUIntMaxType()));
|
||||||
DefineType("__PTRDIFF_TYPE__", TI.getPtrDiffType(0), Builder);
|
DefineType("__PTRDIFF_TYPE__", TI.getPtrDiffType(LangAS::Default), Builder);
|
||||||
DefineFmt("__PTRDIFF", TI.getPtrDiffType(0), TI, Builder);
|
DefineFmt("__PTRDIFF", TI.getPtrDiffType(LangAS::Default), TI, Builder);
|
||||||
DefineType("__INTPTR_TYPE__", TI.getIntPtrType(), Builder);
|
DefineType("__INTPTR_TYPE__", TI.getIntPtrType(), Builder);
|
||||||
DefineFmt("__INTPTR", TI.getIntPtrType(), TI, Builder);
|
DefineFmt("__INTPTR", TI.getIntPtrType(), TI, Builder);
|
||||||
DefineType("__SIZE_TYPE__", TI.getSizeType(), Builder);
|
DefineType("__SIZE_TYPE__", TI.getSizeType(), Builder);
|
||||||
|
@ -1051,7 +1054,7 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
|
||||||
|
|
||||||
// Define a __POINTER_WIDTH__ macro for stdint.h.
|
// Define a __POINTER_WIDTH__ macro for stdint.h.
|
||||||
Builder.defineMacro("__POINTER_WIDTH__",
|
Builder.defineMacro("__POINTER_WIDTH__",
|
||||||
Twine((int)TI.getPointerWidth(0)));
|
Twine((int)TI.getPointerWidth(LangAS::Default)));
|
||||||
|
|
||||||
// Define __BIGGEST_ALIGNMENT__ to be compatible with gcc.
|
// Define __BIGGEST_ALIGNMENT__ to be compatible with gcc.
|
||||||
Builder.defineMacro("__BIGGEST_ALIGNMENT__",
|
Builder.defineMacro("__BIGGEST_ALIGNMENT__",
|
||||||
|
@ -1164,8 +1167,9 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
|
||||||
DEFINE_LOCK_FREE_MACRO(INT, Int);
|
DEFINE_LOCK_FREE_MACRO(INT, Int);
|
||||||
DEFINE_LOCK_FREE_MACRO(LONG, Long);
|
DEFINE_LOCK_FREE_MACRO(LONG, Long);
|
||||||
DEFINE_LOCK_FREE_MACRO(LLONG, LongLong);
|
DEFINE_LOCK_FREE_MACRO(LLONG, LongLong);
|
||||||
Builder.defineMacro(Prefix + "POINTER_LOCK_FREE",
|
Builder.defineMacro(
|
||||||
getLockFreeValue(TI.getPointerWidth(0), TI));
|
Prefix + "POINTER_LOCK_FREE",
|
||||||
|
getLockFreeValue(TI.getPointerWidth(LangAS::Default), TI));
|
||||||
#undef DEFINE_LOCK_FREE_MACRO
|
#undef DEFINE_LOCK_FREE_MACRO
|
||||||
};
|
};
|
||||||
addLockFreeMacros("__CLANG_ATOMIC_");
|
addLockFreeMacros("__CLANG_ATOMIC_");
|
||||||
|
|
|
@ -16021,9 +16021,8 @@ void Sema::CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr,
|
||||||
return;
|
return;
|
||||||
if (index.isUnsigned() || !index.isNegative()) {
|
if (index.isUnsigned() || !index.isNegative()) {
|
||||||
const auto &ASTC = getASTContext();
|
const auto &ASTC = getASTContext();
|
||||||
unsigned AddrBits =
|
unsigned AddrBits = ASTC.getTargetInfo().getPointerWidth(
|
||||||
ASTC.getTargetInfo().getPointerWidth(ASTC.getTargetAddressSpace(
|
EffectiveType->getCanonicalTypeInternal().getAddressSpace());
|
||||||
EffectiveType->getCanonicalTypeInternal()));
|
|
||||||
if (index.getBitWidth() < AddrBits)
|
if (index.getBitWidth() < AddrBits)
|
||||||
index = index.zext(AddrBits);
|
index = index.zext(AddrBits);
|
||||||
Optional<CharUnits> ElemCharUnits =
|
Optional<CharUnits> ElemCharUnits =
|
||||||
|
|
|
@ -4506,7 +4506,7 @@ static void parseModeAttrArg(Sema &S, StringRef Str, unsigned &DestWidth,
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
if (Str == "pointer")
|
if (Str == "pointer")
|
||||||
DestWidth = S.Context.getTargetInfo().getPointerWidth(0);
|
DestWidth = S.Context.getTargetInfo().getPointerWidth(LangAS::Default);
|
||||||
break;
|
break;
|
||||||
case 11:
|
case 11:
|
||||||
if (Str == "unwind_word")
|
if (Str == "unwind_word")
|
||||||
|
|
|
@ -16707,7 +16707,7 @@ ExprResult Sema::ActOnGNUNullExpr(SourceLocation TokenLoc) {
|
||||||
// The type of __null will be int or long, depending on the size of
|
// The type of __null will be int or long, depending on the size of
|
||||||
// pointers on the target.
|
// pointers on the target.
|
||||||
QualType Ty;
|
QualType Ty;
|
||||||
unsigned pw = Context.getTargetInfo().getPointerWidth(0);
|
unsigned pw = Context.getTargetInfo().getPointerWidth(LangAS::Default);
|
||||||
if (pw == Context.getTargetInfo().getIntWidth())
|
if (pw == Context.getTargetInfo().getIntWidth())
|
||||||
Ty = Context.IntTy;
|
Ty = Context.IntTy;
|
||||||
else if (pw == Context.getTargetInfo().getLongWidth())
|
else if (pw == Context.getTargetInfo().getLongWidth())
|
||||||
|
|
|
@ -2661,7 +2661,9 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range,
|
||||||
// tree? Or should the consumer just recalculate the value?
|
// tree? Or should the consumer just recalculate the value?
|
||||||
// FIXME: Using a dummy value will interact poorly with attribute enable_if.
|
// FIXME: Using a dummy value will interact poorly with attribute enable_if.
|
||||||
IntegerLiteral Size(
|
IntegerLiteral Size(
|
||||||
Context, llvm::APInt::getZero(Context.getTargetInfo().getPointerWidth(0)),
|
Context,
|
||||||
|
llvm::APInt::getZero(
|
||||||
|
Context.getTargetInfo().getPointerWidth(LangAS::Default)),
|
||||||
Context.getSizeType(), SourceLocation());
|
Context.getSizeType(), SourceLocation());
|
||||||
AllocArgs.push_back(&Size);
|
AllocArgs.push_back(&Size);
|
||||||
|
|
||||||
|
|
|
@ -7288,7 +7288,8 @@ static bool handleMSPointerTypeQualifierAttr(TypeProcessingState &State,
|
||||||
|
|
||||||
// Add address space to type based on its attributes.
|
// Add address space to type based on its attributes.
|
||||||
LangAS ASIdx = LangAS::Default;
|
LangAS ASIdx = LangAS::Default;
|
||||||
uint64_t PtrWidth = S.Context.getTargetInfo().getPointerWidth(0);
|
uint64_t PtrWidth =
|
||||||
|
S.Context.getTargetInfo().getPointerWidth(LangAS::Default);
|
||||||
if (PtrWidth == 32) {
|
if (PtrWidth == 32) {
|
||||||
if (Attrs[attr::Ptr64])
|
if (Attrs[attr::Ptr64])
|
||||||
ASIdx = LangAS::ptr64;
|
ASIdx = LangAS::ptr64;
|
||||||
|
|
|
@ -72,7 +72,7 @@ class WalkAST : public StmtVisitor<WalkAST> {
|
||||||
public:
|
public:
|
||||||
WalkAST(BugReporter &br, const CheckerBase *checker, AnalysisDeclContext *ac)
|
WalkAST(BugReporter &br, const CheckerBase *checker, AnalysisDeclContext *ac)
|
||||||
: BR(br), Checker(checker), AC(ac), ASTC(AC->getASTContext()),
|
: BR(br), Checker(checker), AC(ac), ASTC(AC->getASTContext()),
|
||||||
PtrWidth(ASTC.getTargetInfo().getPointerWidth(0)) {}
|
PtrWidth(ASTC.getTargetInfo().getPointerWidth(LangAS::Default)) {}
|
||||||
|
|
||||||
// Statement visitor methods.
|
// Statement visitor methods.
|
||||||
void VisitChildren(Stmt *S);
|
void VisitChildren(Stmt *S);
|
||||||
|
|
|
@ -48,7 +48,7 @@ struct TestCompiler {
|
||||||
std::make_shared<clang::TargetOptions>(compiler.getTargetOpts())));
|
std::make_shared<clang::TargetOptions>(compiler.getTargetOpts())));
|
||||||
|
|
||||||
const clang::TargetInfo &TInfo = compiler.getTarget();
|
const clang::TargetInfo &TInfo = compiler.getTarget();
|
||||||
PtrSize = TInfo.getPointerWidth(0) / 8;
|
PtrSize = TInfo.getPointerWidth(clang::LangAS::Default) / 8;
|
||||||
|
|
||||||
compiler.createFileManager();
|
compiler.createFileManager();
|
||||||
compiler.createSourceManager(compiler.getFileManager());
|
compiler.createSourceManager(compiler.getFileManager());
|
||||||
|
|
Loading…
Reference in New Issue