[LLVM][IR] Use splat syntax when printing ConstantExpr based splats. (#116856)
[llvm-project.git] / clang / test / CodeGen / weak_constant.c
blob67bdd919684d148944f01da151cb0e92237f70d4
1 // RUN: %clang_cc1 -w -emit-llvm %s -O1 -o - | FileCheck %s
2 // This used to "check for bug compatibility with gcc".
3 // Now it checks that that the "weak" declaration makes the value
4 // fully interposable whereas a "selectany" one is handled as constant
5 // and propagated.
7 // CHECK: @x = weak {{.*}}constant i32 123
8 const int x __attribute((weak)) = 123;
10 // CHECK: @y = weak_odr {{.*}}constant i32 234
11 const int y __attribute((selectany)) = 234;
13 int* f(void) {
14 return &x;
17 int g(void) {
18 // CHECK: load i32, ptr @x
19 // CHECK-NOT: ret i32 123
20 return *f();
23 int *k(void) {
24 return &y;
27 int l(void) {
28 // CHECK-NOT: load i32, ptr @y
29 // CHECK: ret i32 234
30 return *k();