]> granicus.if.org Git - clang/commitdiff
R600: Implement getPointerWidthV()
authorTom Stellard <thomas.stellard@amd.com>
Thu, 21 Aug 2014 13:58:40 +0000 (13:58 +0000)
committerTom Stellard <thomas.stellard@amd.com>
Thu, 21 Aug 2014 13:58:40 +0000 (13:58 +0000)
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
test/Sema/sizeof-struct-non-zero-as-member.cl [new file with mode: 0644]

index 24b415d193ba6f2bee58c0d7ec9c843cf62ac724..d1eba5af47051a7da6ec70b04568f5ba4b218888 100644 (file)
@@ -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 (file)
index 0000000..b64c036
--- /dev/null
@@ -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 };