Cameron Esfahani | 1484e0d | 2010-09-15 00:28:12 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-pc-win32 -emit-llvm -O2 -o - %s | FileCheck %s |
| 2 | |
| 3 | // Under Windows 64, int and long are 32-bits. Make sure pointer math doesn't |
| 4 | // cause any sign extensions. |
| 5 | |
Cameron Esfahani | ee0f984 | 2010-09-15 10:52:02 +0000 | [diff] [blame] | 6 | // CHECK: [[P:%.*]] = add i64 %param, -8 |
Benjamin Kramer | bf3a60b | 2010-09-15 12:31:46 +0000 | [diff] [blame] | 7 | // CHECK-NEXT: [[Q:%.*]] = inttoptr i64 [[P]] to [[R:%.*\*]] |
Cameron Esfahani | ee0f984 | 2010-09-15 10:52:02 +0000 | [diff] [blame] | 8 | // CHECK-NEXT: {{%.*}} = getelementptr inbounds [[R]] [[Q]], i64 0, i32 0 |
Cameron Esfahani | 1484e0d | 2010-09-15 00:28:12 +0000 | [diff] [blame] | 9 | |
| 10 | #define CR(Record, TYPE, Field) \ |
| 11 | ((TYPE *) ((unsigned char *) (Record) - (unsigned char *) &(((TYPE *) 0)->Field))) |
| 12 | |
| 13 | typedef struct _LIST_ENTRY { |
| 14 | struct _LIST_ENTRY *ForwardLink; |
| 15 | struct _LIST_ENTRY *BackLink; |
| 16 | } LIST_ENTRY; |
| 17 | |
| 18 | typedef struct { |
| 19 | unsigned long long Signature; |
| 20 | LIST_ENTRY Link; |
| 21 | } MEMORY_MAP; |
| 22 | |
| 23 | int test(unsigned long long param) |
| 24 | { |
| 25 | LIST_ENTRY *Link; |
| 26 | MEMORY_MAP *Entry; |
| 27 | |
| 28 | Link = (LIST_ENTRY *) param; |
| 29 | |
| 30 | Entry = CR (Link, MEMORY_MAP, Link); |
| 31 | return (int) Entry->Signature; |
| 32 | } |