diff options
author | Vikram S. Adve <vadve@cs.uiuc.edu> | 2002-09-27 13:27:14 +0000 |
---|---|---|
committer | Vikram S. Adve <vadve@cs.uiuc.edu> | 2002-09-27 13:27:14 +0000 |
commit | 6ec010a68071cc6839235638cfed1d5827d839a3 (patch) | |
tree | 27689b307b2bd16e4877a43ac94eede65b6de005 | |
parent | 3c94e48722a2d8479038f2b77e347fb3984e203b (diff) |
Simple test for constant expressions constructed from global addresses.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3956 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | test/LLC/globalrefs.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/LLC/globalrefs.c b/test/LLC/globalrefs.c new file mode 100644 index 0000000000..3e3cd0910d --- /dev/null +++ b/test/LLC/globalrefs.c @@ -0,0 +1,40 @@ +/* globalrefs.c - Test constant expressions constructed from global + * addresses and index expressions into global addresses. + * Instead of printing absolute addresses, print out the differences in + * memory addresses to get output that matches that of the native compiler. + */ + +#include <stdio.h> + +#define __STDC_LIMIT_MACROS 1 +#include <inttypes.h> + +struct test { + long A; + struct { unsigned X; unsigned Y; } S; + struct test* next; +}; + +struct test TestArray[10]; +struct test Test1; + +struct test* TestArrayPtr = TestArray; +long* Aptr = &Test1.A; +unsigned* Xptr = &Test1.S.X; + +int +main(int argc, char** argv) +{ + void* a1 = (void*) TestArrayPtr; + void* a2 = (void*) Aptr; + void* a3 = (void*) Xptr; + +#ifdef WANT_ABSOLUTE_ADDRESSES + printf("Aptr = 0x%lx, Xptr = 0x%lx, TestArrayPtr = 0x%lx\n", + Aptr, Xptr, TestArrayPtr); +#endif + + printf("Aptr - TestArrayPtr = 0x%lx, Xptr - Aptr = 0x%lx\n", + (uint64_t) a2 - (uint64_t) a1, (uint64_t) a3 - (uint64_t) a2); + return 0; +} |