From 26f7566ff871cf249f3c4d077afeb79ab2eef670 Mon Sep 17 00:00:00 2001 From: Yaxun Liu Date: Fri, 19 Aug 2016 05:17:25 +0000 Subject: Re-commit [OpenCL] AMDGCN: Fix size_t type There was a premature cast to pointer type in emitPointerArithmetic which caused assertion in tests with assertion enabled. llvm-svn: 279206 --- clang/lib/Basic/TargetInfo.cpp | 5 +++-- clang/lib/Basic/Targets.cpp | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'clang/lib/Basic') diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp index dec8b7cda4e..592b877fadd 100644 --- a/clang/lib/Basic/TargetInfo.cpp +++ b/clang/lib/Basic/TargetInfo.cpp @@ -306,8 +306,9 @@ void TargetInfo::adjust(const LangOptions &Opts) { } LongDoubleWidth = LongDoubleAlign = 128; - assert(PointerWidth == 32 || PointerWidth == 64); - bool Is32BitArch = PointerWidth == 32; + unsigned MaxPointerWidth = getMaxPointerWidth(); + assert(MaxPointerWidth == 32 || MaxPointerWidth == 64); + bool Is32BitArch = MaxPointerWidth == 32; SizeType = Is32BitArch ? UnsignedInt : UnsignedLong; PtrDiffType = Is32BitArch ? SignedInt : SignedLong; IntPtrType = Is32BitArch ? SignedInt : SignedLong; diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index 793b25e9287..36e6d4594fa 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -2004,6 +2004,10 @@ public: } } + uint64_t getMaxPointerWidth() const override { + return getTriple().getArch() == llvm::Triple::amdgcn ? 64 : 32; + } + const char * getClobbers() const override { return ""; } -- cgit v1.2.3