| 1 |
// RUN: %clang_cc1 -x c -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \ |
| 2 |
// RUN: -triple x86_64-unknown-linux -Wno-implicit-function-declaration -fclangir -emit-cir -o %t.cir %s |
| 3 |
// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s |
| 4 |
// RUN: %clang_cc1 -x c++ -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \ |
| 5 |
// RUN: -triple x86_64-unknown-linux -Wno-implicit-function-declaration -fclangir -emit-cir -o %t.cir %s |
| 6 |
// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s |
| 7 |
|
| 8 |
// RUN: %clang_cc1 -x c -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \ |
| 9 |
// RUN: -triple x86_64-unknown-linux -Wno-implicit-function-declaration -fclangir -emit-llvm -o %t.ll %s |
| 10 |
// RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s |
| 11 |
// RUN: %clang_cc1 -x c++ -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \ |
| 12 |
// RUN: -triple x86_64-unknown-linux -Wno-implicit-function-declaration -fclangir -emit-llvm -o %t.ll %s |
| 13 |
// RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s |
| 14 |
|
| 15 |
// RUN: %clang_cc1 -x c -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \ |
| 16 |
// RUN: -triple x86_64-unknown-linux -emit-llvm -Wall -Werror %s -o - \ |
| 17 |
// RUN: | FileCheck %s -check-prefix=OGCG |
| 18 |
// RUN: %clang_cc1 -x c++ -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \ |
| 19 |
// RUN: -triple x86_64-unknown-linux -emit-llvm -Wall -Werror %s -o - \ |
| 20 |
// RUN: | FileCheck %s -check-prefix=OGCG |
| 21 |
|
| 22 |
// This test mimics clang/test/CodeGen/ms-intrinsics.c, which eventually |
| 23 |
// CIR shall be able to support fully. |
| 24 |
|
| 25 |
void *_AddressOfReturnAddress(void); |
| 26 |
void *_ReturnAddress(void); |
| 27 |
|
| 28 |
void *test_ReturnAddress(void) { |
| 29 |
return _ReturnAddress(); |
| 30 |
// CIR-LABEL: test_ReturnAddress |
| 31 |
// CIR: [[ARG:%.*]] = cir.const #cir.int<0> : !u32i |
| 32 |
// CIR: {{%.*}} = cir.return_address([[ARG]]) |
| 33 |
|
| 34 |
// LLVM-LABEL: test_ReturnAddress |
| 35 |
// LLVM: {{%.*}} = call ptr @llvm.returnaddress(i32 0) |
| 36 |
|
| 37 |
// OGCG-LABEL: test_ReturnAddress |
| 38 |
// OGCG: {{%.*}} = call ptr @llvm.returnaddress(i32 0) |
| 39 |
} |
| 40 |
|
| 41 |
#if defined(__i386__) || defined(__x86_64__) || defined (__aarch64__) |
| 42 |
void *test_AddressOfReturnAddress(void) { |
| 43 |
return _AddressOfReturnAddress(); |
| 44 |
// CIR-LABEL: test_AddressOfReturnAddress |
| 45 |
// CIR: %[[ADDR:.*]] = cir.address_of_return_address : !cir.ptr<!u8i> |
| 46 |
// CIR: %{{.*}} = cir.cast bitcast %[[ADDR]] : !cir.ptr<!u8i> -> !cir.ptr<!void> |
| 47 |
|
| 48 |
// LLVM-LABEL: test_AddressOfReturnAddress |
| 49 |
// LLVM: call ptr @llvm.addressofreturnaddress.p0() |
| 50 |
|
| 51 |
// OGCG-LABEL: test_AddressOfReturnAddress |
| 52 |
// OGCG: call ptr @llvm.addressofreturnaddress.p0() |
| 53 |
} |
| 54 |
#endif |