Preserve address space information through member accesses, e.g.,
__attribute__((address_space(1))) struct {int arr[ 3 ]; } *p1;
... = p1->arr[2]; // load from address space 1
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76717 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/CodeGen/address-space-field1.c b/test/CodeGen/address-space-field1.c
new file mode 100644
index 0000000..e7c655a
--- /dev/null
+++ b/test/CodeGen/address-space-field1.c
@@ -0,0 +1,20 @@
+// RUN: clang-cc -emit-llvm < %s -o %t &&
+// RUN: grep addrspace\(1\) %t | count 9 &&
+// RUN: grep addrspace\(2\) %t | count 9
+
+// Check that we don't lose the address space when accessing a member
+// of a structure.
+
+#define __addr1 __attribute__((address_space(1)))
+#define __addr2 __attribute__((address_space(2)))
+
+typedef struct S {
+ int a;
+ int b;
+} S;
+
+void test_addrspace(__addr1 S* p1, __addr2 S*p2) {
+ // swap
+ p1->a = p2->b;
+ p1->b = p2->a;
+}