| 1 |
// RUN: %clang_cc1 -triple aarch64-none-linux-android21 -fclangir -emit-cir %s -o %t.cir |
| 2 |
// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s |
| 3 |
// RUN: %clang_cc1 -triple aarch64-none-linux-android21 -fclangir -emit-llvm %s -o %t-cir.ll |
| 4 |
// RUN: FileCheck --check-prefix=LLVM --input-file=%t-cir.ll %s |
| 5 |
// RUN: %clang_cc1 -triple aarch64-none-linux-android21 -emit-llvm %s -o %t.ll |
| 6 |
// RUN: FileCheck --check-prefix=OGCG --input-file=%t.ll %s |
| 7 |
|
| 8 |
char g_str[] = "1234"; |
| 9 |
|
| 10 |
// CIR: cir.global external @g_str = #cir.const_array<"1234\00" : !cir.array<!s8i x 5>> : !cir.array<!s8i x 5> |
| 11 |
|
| 12 |
char g_oversized[100] = "123"; |
| 13 |
|
| 14 |
// CIR: cir.global external @g_oversized = #cir.const_array<"123" : !cir.array<!s8i x 3>, trailing_zeros> : !cir.array<!s8i x 100> |
| 15 |
|
| 16 |
char g_exact[4] = "123"; |
| 17 |
|
| 18 |
// CIR: cir.global external @g_exact = #cir.const_array<"123\00" : !cir.array<!s8i x 4>> : !cir.array<!s8i x 4> |
| 19 |
|
| 20 |
// CIR: cir.global "private" constant cir_private dso_local @[[STR1_GLOBAL:.*]] = #cir.const_array<"1\00" : !cir.array<!s8i x 2>> : !cir.array<!s8i x 2> |
| 21 |
// CIR: cir.global "private" constant cir_private dso_local @[[STR2_GLOBAL:.*]] = #cir.zero : !cir.array<!s8i x 1> |
| 22 |
// CIR: cir.global "private" constant cir_private dso_local @[[STR3_GLOBAL:.*]] = #cir.zero : !cir.array<!s8i x 2> |
| 23 |
|
| 24 |
// LLVM: @[[STR1_GLOBAL:.*]] = private constant [2 x i8] c"1\00" |
| 25 |
// LLVM: @[[STR2_GLOBAL:.*]] = private constant [1 x i8] zeroinitializer |
| 26 |
// LLVM: @[[STR3_GLOBAL:.*]] = private constant [2 x i8] zeroinitializer |
| 27 |
|
| 28 |
// OGCG: @[[STR1_GLOBAL:.*]] = private unnamed_addr constant [2 x i8] c"1\00" |
| 29 |
// OGCG: @[[STR2_GLOBAL:.*]] = private unnamed_addr constant [1 x i8] zeroinitializer |
| 30 |
// OGCG: @[[STR3_GLOBAL:.*]] = private unnamed_addr constant [2 x i8] zeroinitializer |
| 31 |
|
| 32 |
char *f1() { |
| 33 |
return "1"; |
| 34 |
} |
| 35 |
|
| 36 |
// CIR: cir.func{{.*}} @f1() |
| 37 |
// CIR: %[[STR:.*]] = cir.get_global @[[STR1_GLOBAL]] : !cir.ptr<!cir.array<!s8i x 2>> |
| 38 |
|
| 39 |
// LLVM: define{{.*}} ptr @f1() |
| 40 |
// LLVM: store ptr @[[STR1_GLOBAL]], ptr {{.*}} |
| 41 |
|
| 42 |
// OGCG: define {{.*}}ptr @f1() |
| 43 |
// OGCG: ret ptr @[[STR1_GLOBAL]] |
| 44 |
|
| 45 |
char *f2() { |
| 46 |
return ""; |
| 47 |
} |
| 48 |
|
| 49 |
// CIR: cir.func{{.*}} @f2() |
| 50 |
// CIR: %[[STR2:.*]] = cir.get_global @[[STR2_GLOBAL]] : !cir.ptr<!cir.array<!s8i x 1>> |
| 51 |
|
| 52 |
// LLVM: define{{.*}} ptr @f2() |
| 53 |
// LLVM: store ptr @[[STR2_GLOBAL]], ptr {{.*}} |
| 54 |
|
| 55 |
// OGCG: define{{.*}} ptr @f2() |
| 56 |
// OGCG: ret ptr @[[STR2_GLOBAL]] |
| 57 |
|
| 58 |
char *f3() { |
| 59 |
return "\00"; |
| 60 |
} |
| 61 |
|
| 62 |
// CIR: cir.func{{.*}} @f3() |
| 63 |
// CIR: %[[STR3:.*]] = cir.get_global @[[STR3_GLOBAL]] : !cir.ptr<!cir.array<!s8i x 2>> |
| 64 |
|
| 65 |
// LLVM: define{{.*}} ptr @f3() |
| 66 |
// LLVM: store ptr @[[STR3_GLOBAL]], ptr {{.*}} |
| 67 |
|
| 68 |
// OGCG: define{{.*}} ptr @f3() |
| 69 |
// OGCG: ret ptr @[[STR3_GLOBAL]] |