1 // RUN: %clang_cc1 -triple i686-linux-gnu -emit-llvm %s -disable-llvm-passes -o - | FileCheck %s --check-prefix=CHECK-O0
2 // RUN: %clang_cc1 -triple i686-linux-gnu -emit-llvm %s -O1 -disable-llvm-passes -o - | FileCheck %s
4 // Check that we add an llvm.invariant.start.p0i8 to mark when a global becomes
5 // read-only. If globalopt can fold the initializer, it will then mark the
6 // variable as constant.
8 // Do not produce markers at -O0.
9 // CHECK-O0-NOT: llvm.invariant.start.p0i8
16 // CHECK: @a ={{.*}} global {{.*}} zeroinitializer
17 extern const A a
= A();
24 // CHECK: @b ={{.*}} global {{.*}} zeroinitializer
25 extern const B b
= B();
33 // CHECK: @c ={{.*}} global {{.*}} zeroinitializer
34 extern const C c
= C();
37 // CHECK: @d ={{.*}} global i32 0
38 extern const int d
= f();
41 static const A a
= A();
44 // CHECK: call void @_ZN1AC1Ev(ptr noundef {{[^,]*}} @a)
45 // CHECK: call {{.*}}@llvm.invariant.start.p0(i64 4, ptr @a)
47 // CHECK: call void @_ZN1BC1Ev(ptr noundef {{[^,]*}} @b)
48 // CHECK-NOT: call {{.*}}@llvm.invariant.start.p0(i64 noundef 4, ptr @b)
50 // CHECK: call void @_ZN1CC1Ev(ptr noundef {{[^,]*}} @c)
51 // CHECK-NOT: call {{.*}}@llvm.invariant.start.p0(i64 noundef 4, ptr @c)
53 // CHECK: call noundef i32 @_Z1fv(
54 // CHECK: store {{.*}}, ptr @d
55 // CHECK: call {{.*}}@llvm.invariant.start.p0(i64 4, ptr @d)
57 // CHECK-LABEL: define{{.*}} void @_Z1ev(
58 // CHECK: call void @_ZN1AC1Ev(ptr noundef {{[^,]*}} @_ZZ1evE1a)
59 // CHECK: call {{.*}}@llvm.invariant.start.p0(i64 4, ptr {{.*}}@_ZZ1evE1a)
60 // CHECK-NOT: llvm.invariant.end