yaxunl updated this revision to Diff 181326. yaxunl added a comment. Herald added a subscriber: jfb.
Copy type information from AuxTarget. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D56318/new/ https://reviews.llvm.org/D56318 Files: include/clang/Basic/TargetInfo.h lib/Basic/TargetInfo.cpp lib/Basic/Targets/AMDGPU.cpp lib/Frontend/CompilerInstance.cpp test/SemaCUDA/amdgpu-size_t.cu
Index: test/SemaCUDA/amdgpu-size_t.cu =================================================================== --- /dev/null +++ test/SemaCUDA/amdgpu-size_t.cu @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-pc-windows-msvc -fms-compatibility -fcuda-is-device -fsyntax-only -verify %s + +// expected-no-diagnostics +typedef unsigned __int64 size_t; +typedef __int64 intptr_t; +typedef unsigned __int64 uintptr_t; + Index: lib/Frontend/CompilerInstance.cpp =================================================================== --- lib/Frontend/CompilerInstance.cpp +++ lib/Frontend/CompilerInstance.cpp @@ -929,6 +929,8 @@ // Adjust target options based on codegen options. getTarget().adjustTargetOptions(getCodeGenOpts(), getTargetOpts()); + getTarget().copyAuxTarget(getAuxTarget()); + // rewriter project will change target built-in bool type from its default. if (getFrontendOpts().ProgramAction == frontend::RewriteObjC) getTarget().noSignedCharForObjCBool(); Index: lib/Basic/Targets/AMDGPU.cpp =================================================================== --- lib/Basic/Targets/AMDGPU.cpp +++ lib/Basic/Targets/AMDGPU.cpp @@ -260,6 +260,7 @@ } MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64; + ShouldCopyAuxTarget = true; } void AMDGPUTargetInfo::adjust(LangOptions &Opts) { Index: lib/Basic/TargetInfo.cpp =================================================================== --- lib/Basic/TargetInfo.cpp +++ lib/Basic/TargetInfo.cpp @@ -130,6 +130,7 @@ // Default to an unknown platform name. PlatformName = "unknown"; PlatformMinVersion = VersionTuple(); + ShouldCopyAuxTarget = false; } // Out of line virtual dtor for TargetInfo. @@ -796,3 +797,81 @@ assert(getAccumIBits() >= getUnsignedAccumIBits()); assert(getLongAccumIBits() >= getUnsignedLongAccumIBits()); } + +void TargetInfo::copyAuxTarget(TargetInfo *Aux) { + if (!ShouldCopyAuxTarget) + return; + + PointerWidth = Aux->PointerWidth; + PointerAlign = Aux->PointerAlign; + BoolWidth = Aux->BoolWidth; + BoolAlign = Aux->BoolAlign; + IntWidth = Aux->IntWidth; + IntAlign = Aux->IntAlign; + LongWidth = Aux->LongWidth; + LongAlign = Aux->LongAlign; + LongLongWidth = Aux->LongLongWidth; + LongLongAlign = Aux->LongLongAlign; + + // Fixed point default bit widths + ShortAccumWidth = Aux->ShortAccumWidth; + ShortAccumAlign = Aux->ShortAccumAlign; + AccumWidth = Aux->AccumWidth; + AccumAlign = Aux->AccumAlign; + LongAccumWidth = Aux->LongAccumWidth; + LongAccumAlign = Aux->LongAccumAlign; + ShortFractWidth = Aux->ShortFractWidth; + ShortFractAlign = Aux->ShortFractAlign; + FractWidth = Aux->FractWidth; + FractAlign = Aux->FractAlign; + LongFractWidth = Aux->LongFractWidth; + LongFractAlign = Aux->LongFractAlign; + + // Fixed point default integral and fractional bit sizes + PaddingOnUnsignedFixedPoint = Aux->PaddingOnUnsignedFixedPoint; + ShortAccumScale = Aux->ShortAccumScale; + AccumScale = Aux->AccumScale; + LongAccumScale = Aux->LongAccumScale; + + SuitableAlign = Aux->SuitableAlign; + DefaultAlignForAttributeAligned = Aux->DefaultAlignForAttributeAligned; + MinGlobalAlign = Aux->MinGlobalAlign; + + NewAlign = Aux->NewAlign; + + HalfWidth = Aux->HalfWidth; + HalfAlign = Aux->HalfAlign; + FloatWidth = Aux->FloatWidth; + FloatAlign = Aux->FloatAlign; + DoubleWidth = Aux->DoubleWidth; + DoubleAlign = Aux->DoubleAlign; + LongDoubleWidth = Aux->LongDoubleWidth; + LongDoubleAlign = Aux->LongDoubleAlign; + Float128Align = Aux->Float128Align; + LargeArrayMinWidth = Aux->LargeArrayMinWidth; + LargeArrayAlign = Aux->LargeArrayAlign; + MaxVectorAlign = Aux->MaxVectorAlign; + MaxTLSAlign = Aux->MaxTLSAlign; + + SizeType = Aux->SizeType; + PtrDiffType = Aux->PtrDiffType; + IntMaxType = Aux->IntMaxType; + IntPtrType = Aux->IntPtrType; + WCharType = Aux->WCharType; + WIntType = Aux->WIntType; + Char16Type = Aux->Char16Type; + Char32Type = Aux->Char32Type; + Int64Type = Aux->Int64Type; + SigAtomicType = Aux->SigAtomicType; + ProcessIDType = Aux->ProcessIDType; + UseSignedCharForObjCBool = Aux->UseSignedCharForObjCBool; + UseBitFieldTypeAlignment = Aux->UseBitFieldTypeAlignment; + UseZeroLengthBitfieldAlignment = Aux->UseZeroLengthBitfieldAlignment; + UseExplicitBitFieldAlignment = Aux->UseExplicitBitFieldAlignment; + ZeroLengthBitfieldBoundary = Aux->ZeroLengthBitfieldBoundary; + HalfFormat = Aux->HalfFormat; + FloatFormat = Aux->FloatFormat; + DoubleFormat = Aux->DoubleFormat; + LongDoubleFormat = Aux->LongDoubleFormat; + Float128Format = Aux->Float128Format; +} Index: include/clang/Basic/TargetInfo.h =================================================================== --- include/clang/Basic/TargetInfo.h +++ include/clang/Basic/TargetInfo.h @@ -128,6 +128,8 @@ unsigned IsRenderScriptTarget : 1; + bool ShouldCopyAuxTarget; + // TargetInfo Constructor. Default initializes all fields. TargetInfo(const llvm::Triple &T); @@ -1332,6 +1334,9 @@ return true; } + /// Copy type and layout related info. + virtual void copyAuxTarget(TargetInfo *Aux); + protected: virtual uint64_t getPointerWidthV(unsigned AddrSpace) const { return PointerWidth;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits