blob: db87a375152a69e8485a68550081b5133babe5bb [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -emit-llvm < %s -o %t
Daniel Dunbar4fcfde42009-11-08 01:45:36 +00002// RUN: grep volatile %t | count 29
Mike Stumpad97cd42009-05-26 23:10:55 +00003// RUN: grep memcpy %t | count 7
Eli Friedman1e692ac2008-06-13 23:01:12 +00004
Mike Stumpcb9b0102009-11-03 23:32:42 +00005// The number 29 comes from the current codegen for volatile loads;
Eli Friedman1e692ac2008-06-13 23:01:12 +00006// if this number changes, it's not necessarily something wrong, but
7// something has changed to affect volatile load/store codegen
8
9int S;
10volatile int vS;
11
12int* pS;
13volatile int* pvS;
14
15int A[10];
16volatile int vA[10];
17
18struct { int x; } F;
19struct { volatile int x; } vF;
20
21struct { int x; } F2;
22volatile struct { int x; } vF2;
23volatile struct { int x; } *vpF2;
24
25struct { struct { int y; } x; } F3;
26volatile struct { struct { int y; } x; } vF3;
27
28struct { int x:3; } BF;
29struct { volatile int x:3; } vBF;
30
31typedef int v4si __attribute__ ((vector_size (16)));
32v4si V;
33volatile v4si vV;
34
35typedef __attribute__(( ext_vector_type(4) )) int extv4;
36extv4 VE;
37volatile extv4 vVE;
38
39volatile struct {int x;} aggFct(void);
40
Mike Stumpcb9b0102009-11-03 23:32:42 +000041typedef volatile int volatile_int;
42volatile_int vtS;
43
John McCall13591ed2009-07-25 04:36:53 +000044int main() {
Eli Friedman1e692ac2008-06-13 23:01:12 +000045 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 Stumpcb9b0102009-11-03 23:32:42 +000068 i=vtS;
Eli Friedman1e692ac2008-06-13 23:01:12 +000069
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 Dunbared3849b2008-11-19 09:36:46 +000085 vBF.x=i;
Eli Friedman1e692ac2008-06-13 23:01:12 +000086 V[3]=i;
87 vV[3]=i;
Mike Stumpcb9b0102009-11-03 23:32:42 +000088 vtS=i;
Eli Friedman1e692ac2008-06-13 23:01:12 +000089
90 // other ops:
91 ++S;
92 ++vS;
93 i+=S;
94 i+=vS;
Mike Stumpcb9b0102009-11-03 23:32:42 +000095 ++vtS;
Mike Stump49d1cd52009-05-26 22:03:21 +000096 (void)vF2;
97 vF2 = vF2;
98 vF2 = vF2 = vF2;
Mike Stumpad97cd42009-05-26 23:10:55 +000099 vF2 = (vF2, vF2);
Eli Friedman1e692ac2008-06-13 23:01:12 +0000100}