Daniel Dunbar | 4fcfde4 | 2009-11-08 01:45:36 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -emit-llvm < %s -o %t |
| 2 | // RUN: grep volatile %t | count 29 |
Mike Stump | ad97cd4 | 2009-05-26 23:10:55 +0000 | [diff] [blame] | 3 | // RUN: grep memcpy %t | count 7 |
Eli Friedman | 1e692ac | 2008-06-13 23:01:12 +0000 | [diff] [blame] | 4 | |
Mike Stump | cb9b010 | 2009-11-03 23:32:42 +0000 | [diff] [blame] | 5 | // The number 29 comes from the current codegen for volatile loads; |
Eli Friedman | 1e692ac | 2008-06-13 23:01:12 +0000 | [diff] [blame] | 6 | // if this number changes, it's not necessarily something wrong, but |
| 7 | // something has changed to affect volatile load/store codegen |
| 8 | |
| 9 | int S; |
| 10 | volatile int vS; |
| 11 | |
| 12 | int* pS; |
| 13 | volatile int* pvS; |
| 14 | |
| 15 | int A[10]; |
| 16 | volatile int vA[10]; |
| 17 | |
| 18 | struct { int x; } F; |
| 19 | struct { volatile int x; } vF; |
| 20 | |
| 21 | struct { int x; } F2; |
| 22 | volatile struct { int x; } vF2; |
| 23 | volatile struct { int x; } *vpF2; |
| 24 | |
| 25 | struct { struct { int y; } x; } F3; |
| 26 | volatile struct { struct { int y; } x; } vF3; |
| 27 | |
| 28 | struct { int x:3; } BF; |
| 29 | struct { volatile int x:3; } vBF; |
| 30 | |
| 31 | typedef int v4si __attribute__ ((vector_size (16))); |
| 32 | v4si V; |
| 33 | volatile v4si vV; |
| 34 | |
| 35 | typedef __attribute__(( ext_vector_type(4) )) int extv4; |
| 36 | extv4 VE; |
| 37 | volatile extv4 vVE; |
| 38 | |
| 39 | volatile struct {int x;} aggFct(void); |
| 40 | |
Mike Stump | cb9b010 | 2009-11-03 23:32:42 +0000 | [diff] [blame] | 41 | typedef volatile int volatile_int; |
| 42 | volatile_int vtS; |
| 43 | |
John McCall | 13591ed | 2009-07-25 04:36:53 +0000 | [diff] [blame] | 44 | int main() { |
Eli Friedman | 1e692ac | 2008-06-13 23:01:12 +0000 | [diff] [blame] | 45 | int i; |
| 46 | |
| 47 | // load |
| 48 | i=S; |
| 49 | i=vS; |
| 50 | i=*pS; |
| 51 | i=*pvS; |
| 52 | i=A[2]; |
| 53 | i=vA[2]; |
| 54 | i=F.x; |
| 55 | i=vF.x; |
| 56 | i=F2.x; |
| 57 | i=vF2.x; |
| 58 | i=vpF2->x; |
| 59 | i=F3.x.y; |
| 60 | i=vF3.x.y; |
| 61 | i=BF.x; |
| 62 | i=vBF.x; |
| 63 | i=V[3]; |
| 64 | i=vV[3]; |
| 65 | i=VE.yx[1]; |
| 66 | i=vVE.zy[1]; |
| 67 | i = aggFct().x; |
Mike Stump | cb9b010 | 2009-11-03 23:32:42 +0000 | [diff] [blame] | 68 | i=vtS; |
Eli Friedman | 1e692ac | 2008-06-13 23:01:12 +0000 | [diff] [blame] | 69 | |
| 70 | |
| 71 | // store |
| 72 | S=i; |
| 73 | vS=i; |
| 74 | *pS=i; |
| 75 | *pvS=i; |
| 76 | A[2]=i; |
| 77 | vA[2]=i; |
| 78 | F.x=i; |
| 79 | vF.x=i; |
| 80 | F2.x=i; |
| 81 | vF2.x=i; |
| 82 | vpF2->x=i; |
| 83 | vF3.x.y=i; |
| 84 | BF.x=i; |
Daniel Dunbar | ed3849b | 2008-11-19 09:36:46 +0000 | [diff] [blame] | 85 | vBF.x=i; |
Eli Friedman | 1e692ac | 2008-06-13 23:01:12 +0000 | [diff] [blame] | 86 | V[3]=i; |
| 87 | vV[3]=i; |
Mike Stump | cb9b010 | 2009-11-03 23:32:42 +0000 | [diff] [blame] | 88 | vtS=i; |
Eli Friedman | 1e692ac | 2008-06-13 23:01:12 +0000 | [diff] [blame] | 89 | |
| 90 | // other ops: |
| 91 | ++S; |
| 92 | ++vS; |
| 93 | i+=S; |
| 94 | i+=vS; |
Mike Stump | cb9b010 | 2009-11-03 23:32:42 +0000 | [diff] [blame] | 95 | ++vtS; |
Mike Stump | 49d1cd5 | 2009-05-26 22:03:21 +0000 | [diff] [blame] | 96 | (void)vF2; |
| 97 | vF2 = vF2; |
| 98 | vF2 = vF2 = vF2; |
Mike Stump | ad97cd4 | 2009-05-26 23:10:55 +0000 | [diff] [blame] | 99 | vF2 = (vF2, vF2); |
Eli Friedman | 1e692ac | 2008-06-13 23:01:12 +0000 | [diff] [blame] | 100 | } |