Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGen / arm-cmse-nonsecure.c
blob3310f0cbd0e9b22e9da7ab804e36704b74c960fe
1 // RUN: %clang_cc1 -triple thumbv8m.base-unknown-unknown-eabi -emit-llvm -mrelocation-model static -o - %s | FileCheck %s
2 // RUN: %clang_cc1 -triple thumbebv8m.base-unknown-unknown-eabi -emit-llvm -mrelocation-model static -o - %s | FileCheck %s
4 #include <arm_cmse.h>
6 unsigned test_cmse_primitives(void *p) {
7 // CHECK: define {{.*}} i32 @test_cmse_primitives
8 cmse_address_info_t tt_val, ttt_val;
9 unsigned sum;
11 tt_val = cmse_TT(p);
12 ttt_val = cmse_TTT(p);
13 // CHECK: call i32 @llvm.arm.cmse.tt
14 // CHECK: call i32 @llvm.arm.cmse.ttt
15 // CHECK-NOT: llvm.arm.cmse.tta
16 // CHECK-NOT: llvm.arm.cmse.ttat
18 sum = tt_val.value;
19 sum += ttt_val.value;
21 sum += tt_val.flags.mpu_region;
22 sum += tt_val.flags.mpu_region_valid;
23 sum += tt_val.flags.read_ok;
24 sum += tt_val.flags.readwrite_ok;
26 return sum;
29 void *test_address_range(void *p) {
30 // CHECK: define {{.*}} ptr @test_address_range
31 return cmse_check_address_range(p, 128, CMSE_MPU_UNPRIV
32 | CMSE_MPU_READWRITE
33 | CMSE_MPU_READ);
34 // CHECK: call i32 @llvm.arm.cmse.tt
35 // CHECK: call i32 @llvm.arm.cmse.ttt
36 // CHECK-NOT: llvm.arm.cmse.tta
37 // CHECK-NOT: llvm.arm.cmse.ttat
40 typedef struct {
41 int x, y, z;
42 } Point;
44 void *test_pointed_object(void *p) {
45 // CHECK: define {{.*}} ptr @test_pointed_object
46 Point *pt = (Point *)p;
47 cmse_check_pointed_object(pt, CMSE_MPU_READ);
48 // CHECK: call i32 @llvm.arm.cmse.tt
49 // CHECK: call i32 @llvm.arm.cmse.ttt
50 // CHECK-NOT: call i32 @llvm.arm.cmse.tta
51 // CHECK-NOT: call i32 @llvm.arm.cmse.ttat