1
- // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
1
+ // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -Wno-unused-value - emit-cir %s -o %t.cir
2
2
// RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR
3
- // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -S -emit-llvm %s -o %t.ll
3
+ // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -Wno-unused-value - S -emit-llvm %s -o %t.ll
4
4
// RUN: FileCheck --input-file=%t.ll %s -check-prefix=LLVM
5
5
6
6
@@ -52,7 +52,7 @@ struct G g(int x, int y, int z) {
52
52
}
53
53
54
54
// CIR: cir.func @g
55
- // CIR: %[[RETVAL:.*]] = cir.alloca !ty_22G22, !cir.ptr<!ty_22G22>, ["__retval"] {alignment = 2 : i64} loc(#loc18)
55
+ // CIR: %[[RETVAL:.*]] = cir.alloca !ty_22G22, !cir.ptr<!ty_22G22>, ["__retval"] {alignment = 2 : i64}
56
56
// CIR: %[[X:.*]] = cir.get_member %[[RETVAL]][0] {name = "x"}
57
57
// CIR: cir.store {{.*}}, %[[X]] : !s16i
58
58
// CIR: %[[Y:.*]] = cir.get_member %[[RETVAL]][1] {name = "y"}
@@ -64,4 +64,43 @@ struct G g(int x, int y, int z) {
64
64
65
65
// Nothing meaningful to test for LLVM codegen here.
66
66
// FIXME: ABI note, LLVM lowering differs from traditional LLVM codegen here,
67
- // because the former does a memcopy + i48 load.
67
+ // because the former does a memcopy + i48 load.
68
+
69
+ typedef struct { unsigned long pgprot ; } pgprot_t ;
70
+ void split_large_page (unsigned long addr , pgprot_t prot )
71
+ {
72
+ (addr ? prot : ((pgprot_t ) { 0x001 } )).pgprot ;
73
+ }
74
+
75
+ // CIR-LABEL: @split_large_page
76
+ // CIR: %[[VAL_2:.*]] = cir.alloca !u64i, !cir.ptr<!u64i>, ["addr", init] {alignment = 8 : i64}
77
+ // CIR: %[[VAL_3:.*]] = cir.alloca !ty_22pgprot_t22, !cir.ptr<!ty_22pgprot_t22>, ["prot", init] {alignment = 8 : i64}
78
+ // CIR: %[[VAL_4:.*]] = cir.alloca !ty_22pgprot_t22, !cir.ptr<!ty_22pgprot_t22>, ["tmp"] {alignment = 8 : i64}
79
+ // CIR: cir.store {{.*}}, %[[VAL_2]] : !u64i, !cir.ptr<!u64i>
80
+ // CIR: cir.store {{.*}}, %[[VAL_3]] : !ty_22pgprot_t22, !cir.ptr<!ty_22pgprot_t22>
81
+ // CIR: %[[VAL_5:.*]] = cir.load %[[VAL_2]] : !cir.ptr<!u64i>, !u64i
82
+ // CIR: %[[VAL_6:.*]] = cir.cast(int_to_bool, %[[VAL_5]] : !u64i), !cir.bool
83
+ // CIR: cir.if %[[VAL_6]] {
84
+ // CIR: cir.copy %[[VAL_3]] to %[[VAL_4]] : !cir.ptr<!ty_22pgprot_t22>
85
+ // CIR: } else {
86
+ // CIR: %[[VAL_7:.*]] = cir.get_member %[[VAL_4]][0] {name = "pgprot"} : !cir.ptr<!ty_22pgprot_t22> -> !cir.ptr<!u64i>
87
+ // CIR: %[[VAL_8:.*]] = cir.const #cir.int<1> : !s32i
88
+ // CIR: %[[VAL_9:.*]] = cir.cast(integral, %[[VAL_8]] : !s32i), !u64i
89
+ // CIR: cir.store %[[VAL_9]], %[[VAL_7]] : !u64i, !cir.ptr<!u64i>
90
+ // CIR: }
91
+ // CIR: %[[VAL_10:.*]] = cir.get_member %[[VAL_4]][0] {name = "pgprot"} : !cir.ptr<!ty_22pgprot_t22> -> !cir.ptr<!u64i>
92
+ // CIR: %[[VAL_11:.*]] = cir.load %[[VAL_10]] : !cir.ptr<!u64i>, !u64i
93
+ // CIR: cir.return
94
+ // CIR: }
95
+
96
+ // CHECK-LABEL: @split_large_page
97
+ // CHECK: br i1 {{.*}}, label %[[TRUE:[a-z0-9]+]], label %[[FALSE:[a-z0-9]+]]
98
+ // CHECK: [[FALSE]]:
99
+ // CHECK: %[[GEP:.*]] = getelementptr {{.*}}, ptr %[[ADDR:.*]], i32 0, i32 0
100
+ // CHECK: store i64 1, ptr %[[GEP]], align 8
101
+ // CHECK: br label %[[EXIT:[a-z0-9]+]]
102
+ // CHECK: [[TRUE]]:
103
+ // CHECK: call void @llvm.memcpy.p0.p0.i32(ptr %[[ADDR]], ptr {{.*}}, i32 8, i1 false)
104
+ // CHECK: br label %[[EXIT]]
105
+ // CHECK: [[EXIT]]:
106
+ // CHECK: ret void
0 commit comments