File: volatile.cpp

package info (click to toggle)
llvm-toolchain-18 1%3A18.1.8-18
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,908,340 kB
  • sloc: cpp: 6,667,937; ansic: 1,440,452; asm: 883,619; python: 230,549; objc: 76,880; f90: 74,238; lisp: 35,989; pascal: 16,571; sh: 10,229; perl: 7,459; ml: 5,047; awk: 3,523; makefile: 2,987; javascript: 2,149; xml: 892; fortran: 649; cs: 573
file content (43 lines) | stat: -rw-r--r-- 1,876 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// RUN: %clang_cc1 -O2 -triple=x86_64-unknown-linux-gnu -emit-llvm %s -o -  | FileCheck %s -check-prefix CHECK
struct agg 
{
int a ;
int b ;
} t;
struct agg a;
int vt=10;
_Complex float cf;
int volatile vol =10;
void f0() {
    const_cast<volatile _Complex float &>(cf) = const_cast<volatile _Complex float&>(cf) + 1;
//  CHECK: %cf.real = load volatile float, ptr @cf
//  CHECK: %cf.imag = load volatile float, ptr getelementptr
//  CHECK: %add.r = fadd float %cf.real, 1.000000e+00
//  CHECK: %add.i = fadd float %cf.imag, 0.000000e+00
//  CHECK: store volatile float %add.r
//  CHECK: store volatile float %add.i, ptr getelementptr
      static_cast<volatile _Complex float &>(cf) = static_cast<volatile _Complex float&>(cf) + 1;
//  CHECK: %cf.real1 = load volatile float, ptr @cf
//  CHECK: %cf.imag2 = load volatile float, ptr getelementptr
//  CHECK: %add.r3 = fadd float %cf.real1, 1.000000e+00
//  CHECK: %add.i4 = fadd float %cf.imag2, 0.000000e+00
//  CHECK: store volatile float %add.r3, ptr @cf
//  CHECK: store volatile float %add.i4, ptr getelementptr
    const_cast<volatile  int  &>(a.a) = const_cast<volatile int &>(t.a) ;
//  CHECK: %0 = load volatile i32, ptr @t
//  CHECK: store volatile i32 %0, ptr @a
    static_cast<volatile  int  &>(a.b) = static_cast<volatile int  &>(t.a) ;
//  CHECK: %1 = load volatile i32, ptr @t
//  CHECK: store volatile i32 %1, ptr getelementptr
    const_cast<volatile int&>(vt) = const_cast<volatile int&>(vt) + 1;
//  CHECK: %2 = load volatile i32, ptr @vt
//  CHECK: %add = add nsw i32 %2, 1
//  CHECK: store volatile i32 %add, ptr @vt
     static_cast<volatile int&>(vt) = static_cast<volatile int&>(vt) + 1;
//  CHECK: %3 = load volatile i32, ptr @vt
//  CHECK: %add5 = add nsw i32 %3, 1
//  CHECK: store volatile i32 %add5, ptr @vt
    vt = const_cast<int&>(vol);
//  %4 = load i32, ptr @vol
//  store i32 %4, ptr @vt
}