summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Basic/Targets.cpp17
-rw-r--r--clang/test/Sema/sizeof-struct-non-zero-as-member.cl18
2 files changed, 35 insertions, 0 deletions
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index 24b415d193b..d1eba5af470 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/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/clang/test/Sema/sizeof-struct-non-zero-as-member.cl b/clang/test/Sema/sizeof-struct-non-zero-as-member.cl
new file mode 100644
index 00000000000..b64c03619ca
--- /dev/null
+++ b/clang/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 };
OpenPOWER on IntegriCloud