| 1 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -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 -Wno-unused-value -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 -Wno-unused-value -emit-llvm %s -o %t.ll |
| 6 |
// RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG |
| 7 |
|
| 8 |
double fabs(double x) { |
| 9 |
return __builtin_fabs(x); |
| 10 |
} |
| 11 |
|
| 12 |
// CIR: {{.*}} = cir.fabs {{.*}} : !cir.double |
| 13 |
// LLVM: {{.*}} = call double @llvm.fabs.f64(double {{.*}}) |
| 14 |
// OGCG: {{.*}} = call double @llvm.fabs.f64(double {{.*}}) |
| 15 |
|
| 16 |
extern "C" void *test_return_address(void) { |
| 17 |
return __builtin_return_address(1); |
| 18 |
|
| 19 |
// CIR-LABEL: test_return_address |
| 20 |
// CIR: [[ARG:%.*]] = cir.const #cir.int<1> : !u32i |
| 21 |
// CIR: {{%.*}} = cir.return_address([[ARG]]) |
| 22 |
|
| 23 |
// LLVM-LABEL: @test_return_address |
| 24 |
// LLVM: {{%.*}} = call ptr @llvm.returnaddress(i32 1) |
| 25 |
|
| 26 |
// OGCG-LABEL: @test_return_address |
| 27 |
// OGCG: {{%.*}} = call ptr @llvm.returnaddress(i32 1) |
| 28 |
} |
| 29 |
|
| 30 |
extern "C" void *test_frame_address(void) { |
| 31 |
return __builtin_frame_address(1); |
| 32 |
|
| 33 |
// CIR-LABEL: test_frame_address |
| 34 |
// CIR: [[ARG:%.*]] = cir.const #cir.int<1> : !u32i |
| 35 |
// CIR: %[[ADDR:.*]] = cir.frame_address([[ARG]]) : !cir.ptr<!u8i> |
| 36 |
// CIR: {{%.*}} = cir.cast bitcast %[[ADDR]] : !cir.ptr<!u8i> -> !cir.ptr<!void> |
| 37 |
|
| 38 |
// LLVM-LABEL: @test_frame_address |
| 39 |
// LLVM: {{%.*}} = call ptr @llvm.frameaddress.p0(i32 1) |
| 40 |
|
| 41 |
// OGCG-LABEL: @test_frame_address |
| 42 |
// OGCG: {{%.*}} = call ptr @llvm.frameaddress.p0(i32 1) |
| 43 |
} |