2010-12-04 11:47:34 +08:00
|
|
|
// RUN: %clang_cc1 -Wno-return-type -Wno-unused-value -emit-llvm %s -o - | FileCheck %s
|
2009-05-29 23:46:01 +08:00
|
|
|
|
2010-11-16 18:08:07 +08:00
|
|
|
// CHECK: @i = common global [[INT:i[0-9]+]] 0
|
2009-05-29 23:46:01 +08:00
|
|
|
volatile int i, j, k;
|
|
|
|
volatile int ar[5];
|
|
|
|
volatile char c;
|
2011-07-10 01:41:47 +08:00
|
|
|
// CHECK: @ci = common global [[CINT:.*]] zeroinitializer
|
2009-05-29 23:46:01 +08:00
|
|
|
volatile _Complex int ci;
|
|
|
|
volatile struct S {
|
|
|
|
#ifdef __cplusplus
|
|
|
|
void operator =(volatile struct S&o) volatile;
|
|
|
|
#endif
|
|
|
|
int i;
|
|
|
|
} a, b;
|
|
|
|
|
|
|
|
//void operator =(volatile struct S&o1, volatile struct S&o2) volatile;
|
2009-11-17 16:57:36 +08:00
|
|
|
int printf(const char *, ...);
|
2009-05-29 23:46:01 +08:00
|
|
|
|
2010-11-16 18:08:07 +08:00
|
|
|
|
|
|
|
// Note that these test results are very much specific to C!
|
|
|
|
// Assignments in C++ yield l-values, not r-values, and the situations
|
|
|
|
// that do implicit lvalue-to-rvalue conversion are substantially
|
|
|
|
// reduced.
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @test()
|
2010-11-16 18:08:07 +08:00
|
|
|
void test() {
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK: load volatile [[INT]]* @i
|
2009-05-29 23:46:01 +08:00
|
|
|
i;
|
2013-07-17 13:57:42 +08:00
|
|
|
// CHECK-NEXT: load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0), align 4
|
|
|
|
// CHECK-NEXT: load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1), align 4
|
2010-11-16 18:08:07 +08:00
|
|
|
// CHECK-NEXT: sitofp [[INT]]
|
2009-05-29 23:46:01 +08:00
|
|
|
(float)(ci);
|
2013-07-17 13:57:42 +08:00
|
|
|
// CHECK-NEXT: load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0), align 4
|
|
|
|
// CHECK-NEXT: load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1), align 4
|
2009-05-29 23:46:01 +08:00
|
|
|
(void)ci;
|
2010-11-16 18:08:07 +08:00
|
|
|
// CHECK-NEXT: bitcast
|
|
|
|
// CHECK-NEXT: memcpy
|
2009-05-29 23:46:01 +08:00
|
|
|
(void)a;
|
2013-07-17 13:57:42 +08:00
|
|
|
// CHECK-NEXT: [[R:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0), align 4
|
|
|
|
// CHECK-NEXT: [[I:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1), align 4
|
|
|
|
// CHECK-NEXT: store volatile [[INT]] [[R]], [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0), align 4
|
|
|
|
// CHECK-NEXT: store volatile [[INT]] [[I]], [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1), align 4
|
2009-05-29 23:46:01 +08:00
|
|
|
(void)(ci=ci);
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: [[T:%.*]] = load volatile [[INT]]* @j
|
|
|
|
// CHECK-NEXT: store volatile [[INT]] [[T]], [[INT]]* @i
|
2009-05-29 23:46:01 +08:00
|
|
|
(void)(i=j);
|
2013-07-17 13:57:42 +08:00
|
|
|
// CHECK-NEXT: [[R1:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0), align 4
|
|
|
|
// CHECK-NEXT: [[I1:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1), align 4
|
|
|
|
// CHECK-NEXT: [[R2:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0), align 4
|
|
|
|
// CHECK-NEXT: [[I2:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1), align 4
|
2010-11-16 18:08:07 +08:00
|
|
|
// Not sure why they're ordered this way.
|
|
|
|
// CHECK-NEXT: [[R:%.*]] = add [[INT]] [[R2]], [[R1]]
|
|
|
|
// CHECK-NEXT: [[I:%.*]] = add [[INT]] [[I2]], [[I1]]
|
2013-07-17 13:57:42 +08:00
|
|
|
// CHECK-NEXT: store volatile [[INT]] [[R]], [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0), align 4
|
|
|
|
// CHECK-NEXT: store volatile [[INT]] [[I]], [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1), align 4
|
2009-05-29 23:46:01 +08:00
|
|
|
ci+=ci;
|
2010-11-16 18:08:07 +08:00
|
|
|
|
2013-07-17 13:57:42 +08:00
|
|
|
// CHECK-NEXT: [[R1:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0), align 4
|
|
|
|
// CHECK-NEXT: [[I1:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1), align 4
|
|
|
|
// CHECK-NEXT: [[R2:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0), align 4
|
|
|
|
// CHECK-NEXT: [[I2:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1), align 4
|
2010-11-16 18:08:07 +08:00
|
|
|
// CHECK-NEXT: [[R:%.*]] = add [[INT]] [[R2]], [[R1]]
|
|
|
|
// CHECK-NEXT: [[I:%.*]] = add [[INT]] [[I2]], [[I1]]
|
2013-07-17 13:57:42 +08:00
|
|
|
// CHECK-NEXT: store volatile [[INT]] [[R]], [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0), align 4
|
|
|
|
// CHECK-NEXT: store volatile [[INT]] [[I]], [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1), align 4
|
|
|
|
// CHECK-NEXT: [[R2:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0), align 4
|
|
|
|
// CHECK-NEXT: [[I2:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1), align 4
|
2010-11-16 18:08:07 +08:00
|
|
|
// These additions can be elided
|
|
|
|
// CHECK-NEXT: add [[INT]] [[R]], [[R2]]
|
|
|
|
// CHECK-NEXT: add [[INT]] [[I]], [[I2]]
|
2009-05-29 23:46:01 +08:00
|
|
|
(ci += ci) + ci;
|
2010-11-16 18:08:07 +08:00
|
|
|
// CHECK-NEXT: call void asm
|
2009-05-29 23:46:01 +08:00
|
|
|
asm("nop");
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: load volatile
|
2010-11-16 18:08:07 +08:00
|
|
|
// CHECK-NEXT: add nsw [[INT]]
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: store volatile
|
|
|
|
// CHECK-NEXT: load volatile
|
2010-11-16 18:08:07 +08:00
|
|
|
// CHECK-NEXT: add nsw [[INT]]
|
2009-05-29 23:46:01 +08:00
|
|
|
(i += j) + k;
|
2010-11-16 18:08:07 +08:00
|
|
|
// CHECK-NEXT: call void asm
|
2009-05-29 23:46:01 +08:00
|
|
|
asm("nop");
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: load volatile
|
2010-11-16 18:08:07 +08:00
|
|
|
// CHECK-NEXT: add nsw [[INT]]
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: store volatile
|
2010-11-16 18:08:07 +08:00
|
|
|
// CHECK-NEXT: add nsw [[INT]]
|
2009-05-29 23:46:01 +08:00
|
|
|
(i += j) + 1;
|
2010-11-16 18:08:07 +08:00
|
|
|
// CHECK-NEXT: call void asm
|
2009-05-29 23:46:01 +08:00
|
|
|
asm("nop");
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: load volatile
|
2010-11-16 18:08:07 +08:00
|
|
|
// CHECK-NEXT: add [[INT]]
|
|
|
|
// CHECK-NEXT: add [[INT]]
|
2009-05-29 23:46:01 +08:00
|
|
|
ci+ci;
|
2010-11-16 18:08:07 +08:00
|
|
|
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
2009-05-29 23:46:01 +08:00
|
|
|
__real i;
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: load volatile
|
2009-05-29 23:46:01 +08:00
|
|
|
+ci;
|
2010-11-16 18:08:07 +08:00
|
|
|
// CHECK-NEXT: call void asm
|
2009-05-29 23:46:01 +08:00
|
|
|
asm("nop");
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: store volatile
|
2009-05-29 23:46:01 +08:00
|
|
|
(void)(i=i);
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: store volatile
|
2010-11-16 18:08:07 +08:00
|
|
|
// CHECK-NEXT: sitofp
|
2009-05-29 23:46:01 +08:00
|
|
|
(float)(i=i);
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
2009-05-29 23:46:01 +08:00
|
|
|
(void)i;
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: store volatile
|
2009-05-29 23:46:01 +08:00
|
|
|
i=i;
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: store volatile
|
|
|
|
// CHECK-NEXT: store volatile
|
2009-05-29 23:46:01 +08:00
|
|
|
i=i=i;
|
|
|
|
#ifndef __cplusplus
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: store volatile
|
2009-05-29 23:46:01 +08:00
|
|
|
(void)__builtin_choose_expr(0, i=i, j=j);
|
|
|
|
#endif
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
2010-11-16 18:08:07 +08:00
|
|
|
// CHECK-NEXT: icmp
|
|
|
|
// CHECK-NEXT: br i1
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK: load volatile
|
|
|
|
// CHECK-NEXT: store volatile
|
2010-11-16 18:08:07 +08:00
|
|
|
// CHECK-NEXT: br label
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK: load volatile
|
|
|
|
// CHECK-NEXT: store volatile
|
2010-11-16 18:08:07 +08:00
|
|
|
// CHECK-NEXT: br label
|
2009-05-29 23:46:01 +08:00
|
|
|
k ? (i=i) : (j=j);
|
2010-11-16 18:08:07 +08:00
|
|
|
// CHECK: phi
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: store volatile
|
2009-05-29 23:46:01 +08:00
|
|
|
(void)(i,(i=i));
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: store volatile
|
|
|
|
// CHECK-NEXT: load volatile
|
2009-05-29 23:46:01 +08:00
|
|
|
i=i,i;
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: store volatile
|
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: store volatile
|
2009-05-29 23:46:01 +08:00
|
|
|
(i=j,k=j);
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: store volatile
|
|
|
|
// CHECK-NEXT: load volatile
|
2009-05-29 23:46:01 +08:00
|
|
|
(i=j,k);
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: load volatile
|
2009-05-29 23:46:01 +08:00
|
|
|
(i,j);
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
2010-11-16 18:08:07 +08:00
|
|
|
// CHECK-NEXT: trunc
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: store volatile
|
2010-11-16 18:08:07 +08:00
|
|
|
// CHECK-NEXT: sext
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: store volatile
|
2009-05-29 23:46:01 +08:00
|
|
|
i=c=k;
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: load volatile
|
2010-11-16 18:08:07 +08:00
|
|
|
// CHECK-NEXT: add nsw [[INT]]
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: store volatile
|
2009-05-29 23:46:01 +08:00
|
|
|
i+=k;
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: load volatile
|
2009-05-29 23:46:01 +08:00
|
|
|
ci;
|
|
|
|
#ifndef __cplusplus
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: load volatile
|
2009-05-29 23:46:01 +08:00
|
|
|
(int)ci;
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: load volatile
|
2010-11-16 18:08:07 +08:00
|
|
|
// CHECK-NEXT: icmp ne
|
|
|
|
// CHECK-NEXT: icmp ne
|
|
|
|
// CHECK-NEXT: or i1
|
2009-05-29 23:46:01 +08:00
|
|
|
(_Bool)ci;
|
|
|
|
#endif
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: store volatile
|
|
|
|
// CHECK-NEXT: store volatile
|
2009-05-29 23:46:01 +08:00
|
|
|
ci=ci;
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: store volatile
|
|
|
|
// CHECK-NEXT: store volatile
|
|
|
|
// CHECK-NEXT: store volatile
|
|
|
|
// CHECK-NEXT: store volatile
|
2009-05-29 23:46:01 +08:00
|
|
|
ci=ci=ci;
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: [[T:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
|
|
|
|
// CHECK-NEXT: store volatile [[INT]] [[T]], [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
|
|
|
|
// CHECK-NEXT: store volatile [[INT]] [[T]], [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
|
2009-05-29 23:46:01 +08:00
|
|
|
__imag ci = __imag ci = __imag ci;
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: store volatile
|
2009-05-29 23:46:01 +08:00
|
|
|
__real (i = j);
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
2009-05-29 23:46:01 +08:00
|
|
|
__imag i;
|
|
|
|
|
|
|
|
// ============================================================
|
2009-05-30 00:24:13 +08:00
|
|
|
// FIXME: Test cases we get wrong.
|
2009-05-29 23:46:01 +08:00
|
|
|
|
2009-05-30 00:12:36 +08:00
|
|
|
// A use. We load all of a into a copy of a, then load i. gcc forgets to do
|
|
|
|
// the assignment.
|
2009-05-30 00:24:13 +08:00
|
|
|
// (a = a).i;
|
2009-05-30 00:12:36 +08:00
|
|
|
|
2009-05-29 23:46:01 +08:00
|
|
|
// ============================================================
|
|
|
|
// Test cases where we intentionally differ from gcc, due to suspected bugs in
|
|
|
|
// gcc.
|
|
|
|
|
|
|
|
// Not a use. gcc forgets to do the assignment.
|
2010-11-16 18:08:07 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.memcpy{{.*}}, i1 true
|
|
|
|
// CHECK-NEXT: bitcast
|
|
|
|
// CHECK-NEXT: call void @llvm.memcpy{{.*}}, i1 true
|
2009-05-29 23:46:01 +08:00
|
|
|
((a=a),a);
|
|
|
|
|
|
|
|
// Not a use. gcc gets this wrong, it doesn't emit the copy!
|
|
|
|
// (void)(a=a);
|
|
|
|
|
|
|
|
// Not a use. gcc got this wrong in 4.2 and omitted the side effects
|
|
|
|
// entirely, but it is fixed in 4.4.0.
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: store volatile
|
2009-05-29 23:46:01 +08:00
|
|
|
__imag (i = j);
|
|
|
|
|
|
|
|
#ifndef __cplusplus
|
|
|
|
// A use of the real part
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: store volatile
|
|
|
|
// CHECK-NEXT: store volatile
|
2010-11-16 18:08:07 +08:00
|
|
|
// CHECK-NEXT: sitofp
|
2009-05-29 23:46:01 +08:00
|
|
|
(float)(ci=ci);
|
|
|
|
// Not a use, bug? gcc treats this as not a use, that's probably a bug due to
|
|
|
|
// tree folding ignoring volatile.
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: store volatile
|
|
|
|
// CHECK-NEXT: store volatile
|
2009-05-29 23:46:01 +08:00
|
|
|
(int)(ci=ci);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// A use.
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: store volatile
|
2010-11-16 18:08:07 +08:00
|
|
|
// CHECK-NEXT: sitofp
|
2009-05-29 23:46:01 +08:00
|
|
|
(float)(i=i);
|
|
|
|
// A use. gcc treats this as not a use, that's probably a bug due to tree
|
|
|
|
// folding ignoring volatile.
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: store volatile
|
2009-05-29 23:46:01 +08:00
|
|
|
(int)(i=i);
|
|
|
|
|
|
|
|
// A use.
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: store volatile
|
2010-11-16 18:08:07 +08:00
|
|
|
// CHECK-NEXT: sub
|
2009-05-29 23:46:01 +08:00
|
|
|
-(i=j);
|
|
|
|
// A use. gcc treats this a not a use, that's probably a bug due to tree
|
|
|
|
// folding ignoring volatile.
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: store volatile
|
2009-05-29 23:46:01 +08:00
|
|
|
+(i=k);
|
|
|
|
|
|
|
|
// A use. gcc treats this a not a use, that's probably a bug due to tree
|
|
|
|
// folding ignoring volatile.
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: store volatile
|
|
|
|
// CHECK-NEXT: store volatile
|
2009-05-29 23:46:01 +08:00
|
|
|
__real (ci=ci);
|
|
|
|
|
|
|
|
// A use.
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
2010-11-16 18:08:07 +08:00
|
|
|
// CHECK-NEXT: add
|
2009-05-29 23:46:01 +08:00
|
|
|
i + 0;
|
|
|
|
// A use.
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: store volatile
|
|
|
|
// CHECK-NEXT: load volatile
|
2010-11-16 18:08:07 +08:00
|
|
|
// CHECK-NEXT: add
|
2009-05-29 23:46:01 +08:00
|
|
|
(i=j) + i;
|
|
|
|
// A use. gcc treats this as not a use, that's probably a bug due to tree
|
|
|
|
// folding ignoring volatile.
|
2011-08-13 07:33:52 +08:00
|
|
|
// CHECK-NEXT: load volatile
|
|
|
|
// CHECK-NEXT: store volatile
|
2010-11-16 18:08:07 +08:00
|
|
|
// CHECK-NEXT: add
|
2009-05-29 23:46:01 +08:00
|
|
|
(i=j) + 0;
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
(i,j)=k;
|
|
|
|
(j=k,i)=i;
|
|
|
|
struct { int x; } s, s1;
|
|
|
|
printf("s is at %p\n", &s);
|
|
|
|
printf("s is at %p\n", &(s = s1));
|
|
|
|
printf("s.x is at %p\n", &((s = s1).x));
|
|
|
|
#endif
|
|
|
|
}
|
2010-12-04 11:47:34 +08:00
|
|
|
|
|
|
|
extern volatile enum X x;
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @test1()
|
2010-12-04 11:47:34 +08:00
|
|
|
void test1() {
|
2010-12-04 13:19:12 +08:00
|
|
|
extern void test1_helper(void);
|
|
|
|
test1_helper();
|
|
|
|
// CHECK: call void @test1_helper()
|
2010-12-04 11:47:34 +08:00
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
x;
|
|
|
|
(void) x;
|
|
|
|
return x;
|
|
|
|
}
|
2013-06-12 09:40:06 +08:00
|
|
|
|
2013-06-13 01:31:32 +08:00
|
|
|
// CHECK: define {{.*}} @test2()
|
2013-06-12 09:40:06 +08:00
|
|
|
int test2() {
|
|
|
|
// CHECK: load volatile i32*
|
|
|
|
// CHECK-NEXT: load volatile i32*
|
|
|
|
// CHECK-NEXT: load volatile i32*
|
|
|
|
// CHECK-NEXT: add i32
|
|
|
|
// CHECK-NEXT: add i32
|
|
|
|
// CHECK-NEXT: store volatile i32
|
|
|
|
// CHECK-NEXT: ret i32
|
|
|
|
return i += ci;
|
|
|
|
}
|