r216181 - R600: Implement getPointerWidthV()
Tom Stellard
thomas.stellard at amd.com
Thu Aug 21 06:58:40 PDT 2014
Author: tstellar
Date: Thu Aug 21 08:58:40 2014
New Revision: 216181
URL: http://llvm.org/viewvc/llvm-project?rev=216181&view=rev
Log:
R600: Implement getPointerWidthV()
This fixes a crash in the OCL_ImgProc/Canny OpenCV test.
NOTE: This is a candidate for the 3.5 branch.
Added:
cfe/trunk/test/Sema/sizeof-struct-non-zero-as-member.cl
Modified:
cfe/trunk/lib/Basic/Targets.cpp
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=216181&r1=216180&r2=216181&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Aug 21 08:58:40 2014
@@ -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 "";
}
Added: cfe/trunk/test/Sema/sizeof-struct-non-zero-as-member.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/sizeof-struct-non-zero-as-member.cl?rev=216181&view=auto
==============================================================================
--- cfe/trunk/test/Sema/sizeof-struct-non-zero-as-member.cl (added)
+++ cfe/trunk/test/Sema/sizeof-struct-non-zero-as-member.cl Thu Aug 21 08:58:40 2014
@@ -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 };
More information about the cfe-commits
mailing list