| 1 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c89 -fclangir -emit-cir %s -o %t.cir |
| 2 |
// RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR |
| 3 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c89 -fclangir -emit-llvm %s -o %t-cir.ll |
| 4 |
// RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM |
| 5 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c89 -emit-llvm %s -o %t.ll |
| 6 |
// RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG |
| 7 |
|
| 8 |
// CIR: cir.func {{.*}}@foo(%arg0: !s32i |
| 9 |
// CIR: %0 = cir.alloca !s16i, !cir.ptr<!s16i>, ["x", init] |
| 10 |
// CIR: %1 = cir.cast integral %arg0 : !s32i -> !s16i |
| 11 |
// CIR: cir.store %1, %0 : !s16i, !cir.ptr<!s16i> |
| 12 |
// expected-warning@+1 {{a function definition without a prototype is deprecated}} |
| 13 |
void foo(x) short x; {} |
| 14 |
|
| 15 |
// LLVM: define{{.*}} void @foo(i32 %0) |
| 16 |
// LLVM: %[[X_PTR:.*]] = alloca i16, i64 1, align 2 |
| 17 |
// LLVM: %[[X:.*]] = trunc i32 %0 to i16 |
| 18 |
// LLVM: store i16 %[[X]], ptr %[[X_PTR]], align 2 |
| 19 |
|
| 20 |
// OGCG: define{{.*}} void @foo(i32 noundef %0) |
| 21 |
// OGCG: entry: |
| 22 |
// OGCG: %[[X_PTR:.*]] = alloca i16, align 2 |
| 23 |
// OGCG: %[[X:.*]] = trunc i32 %0 to i16 |
| 24 |
// OGCG: store i16 %[[X]], ptr %[[X_PTR]], align 2 |
| 25 |
|
| 26 |
// CIR: cir.func{{.*}}no_proto dso_local @bar(%arg0: !cir.double |
| 27 |
// CIR: %0 = cir.alloca !cir.float, !cir.ptr<!cir.float>, ["f", init] |
| 28 |
// CIR: %1 = cir.cast floating %arg0 : !cir.double -> !cir.float |
| 29 |
// CIR: cir.store %1, %0 : !cir.float, !cir.ptr<!cir.float> |
| 30 |
// expected-warning@+1 {{a function definition without a prototype is deprecated}} |
| 31 |
void bar(f) float f; {} |
| 32 |
|
| 33 |
// LLVM: define{{.*}} void @bar(double %0) |
| 34 |
// LLVM: %[[F_PTR:.*]] = alloca float, i64 1, align 4 |
| 35 |
// LLVM: %[[F:.*]] = fptrunc double %0 to float |
| 36 |
// LLVM: store float %[[F]], ptr %[[F_PTR]], align 4 |
| 37 |
|
| 38 |
// OGCG: define{{.*}} void @bar(double noundef %0) |
| 39 |
// OGCG: entry: |
| 40 |
// OGCG: %[[F_PTR:.*]] = alloca float, align 4 |
| 41 |
// OGCG: %[[F:.*]] = fptrunc double %0 to float |
| 42 |
// OGCG: store float %[[F]], ptr %[[F_PTR]], align 4 |