volatile.c revision b27442c54b4b48d8b519709c7d683349bd2c71dd
1// RUN: clang-cc -emit-llvm < %s -o %t && 2// RUN: grep volatile %t | count 25 && 3// RUN: grep memcpy %t | count 5 4 5// The number 26 comes from the current codegen for volatile loads; 6// 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 41void main() { 42 int i; 43 44 // load 45 i=S; 46 i=vS; 47 i=*pS; 48 i=*pvS; 49 i=A[2]; 50 i=vA[2]; 51 i=F.x; 52 i=vF.x; 53 i=F2.x; 54 i=vF2.x; 55 i=vpF2->x; 56 i=F3.x.y; 57 i=vF3.x.y; 58 i=BF.x; 59 i=vBF.x; 60 i=V[3]; 61 i=vV[3]; 62 i=VE.yx[1]; 63 i=vVE.zy[1]; 64 i = aggFct().x; 65 66 67 // store 68 S=i; 69 vS=i; 70 *pS=i; 71 *pvS=i; 72 A[2]=i; 73 vA[2]=i; 74 F.x=i; 75 vF.x=i; 76 F2.x=i; 77 vF2.x=i; 78 vpF2->x=i; 79 vF3.x.y=i; 80 BF.x=i; 81 vBF.x=i; 82 V[3]=i; 83 vV[3]=i; 84 85 // other ops: 86 ++S; 87 ++vS; 88 i+=S; 89 i+=vS; 90 (void)vF2; 91 vF2 = vF2; 92 vF2 = vF2 = vF2; 93} 94