From 19854c08f750952223a0475748fd11346c2b63e4 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Thu, 21 Aug 2014 13:58:40 +0000 Subject: [PATCH] R600: Implement getPointerWidthV() This fixes a crash in the OCL_ImgProc/Canny OpenCV test. NOTE: This is a candidate for the 3.5 branch. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216181 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Basic/Targets.cpp | 17 +++++++++++++++++ test/Sema/sizeof-struct-non-zero-as-member.cl | 18 ++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 test/Sema/sizeof-struct-non-zero-as-member.cl diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 24b415d193..d1eba5af47 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -1469,6 +1469,9 @@ static const unsigned R600AddrSpaceMap[] = { 3 // cuda_shared }; +// If you edit the description strings, make sure you update +// getPointerWidthV(). + static const char *DescriptionStringR600 = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128" "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"; @@ -1508,6 +1511,20 @@ public: UseAddrSpaceMapMangling = true; } + uint64_t getPointerWidthV(unsigned AddrSpace) const override { + if (GPU <= GK_CAYMAN) + return 32; + + switch(AddrSpace) { + default: + return 64; + case 0: + case 3: + case 5: + return 32; + } + } + const char * getClobbers() const override { return ""; } diff --git a/test/Sema/sizeof-struct-non-zero-as-member.cl b/test/Sema/sizeof-struct-non-zero-as-member.cl new file mode 100644 index 0000000000..b64c03619c --- /dev/null +++ b/test/Sema/sizeof-struct-non-zero-as-member.cl @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -verify -fsyntax-only -triple r600 -target-cpu verde -S -emit-llvm -o - %s +// expected-no-diagnostics + +// Record lowering was crashing on SI and newer targets, because it +// was using the wrong size for test::ptr. Since global memory +// has 64-bit pointers, sizeof(test::ptr) should be 8. + +struct test_as0 {int *ptr;}; +constant int as0[sizeof(struct test_as0) == 4 ? 1 : -1] = { 0 }; + +struct test_as1 {global int *ptr;}; +constant int as1[sizeof(struct test_as1) == 8 ? 1 : -1] = { 0 }; + +struct test_as2 {constant int *ptr;}; +constant int as2[sizeof(struct test_as2) == 8 ? 1 : -1] = { 0 }; + +struct test_as3 {local int *ptr;}; +constant int as3[sizeof(struct test_as3) == 4 ? 1 : -1] = { 0 }; -- 2.40.0