@@ -213,6 +213,34 @@ typedef struct {
213
213
int c ;
214
214
} V ;
215
215
216
+ void get_volatile (V * v ) {
217
+ v -> b = 3 ;
218
+ }
219
+
220
+ // CIR: cir.func dso_local @get_volatile
221
+ // CIR: [[TMP0:%.*]] = cir.alloca !cir.ptr<!rec_V>, !cir.ptr<!cir.ptr<!rec_V>>, ["v", init] {alignment = 8 : i64}
222
+ // CIR: [[TMP1:%.*]] = cir.const #cir.int<3> : !s32i
223
+ // CIR: [[TMP2:%.*]] = cir.load align(8) [[TMP0]] : !cir.ptr<!cir.ptr<!rec_V>>, !cir.ptr<!rec_V>
224
+ // CIR: [[TMP3:%.*]] = cir.get_member [[TMP2]][0] {name = "b"} : !cir.ptr<!rec_V> -> !cir.ptr<!u64i>
225
+ // CIR: [[TMP4:%.*]] = cir.set_bitfield(#bfi_b, [[TMP3]] : !cir.ptr<!u64i>, [[TMP1]] : !s32i) {is_volatile} -> !s32i
226
+
227
+ // LLVM: define dso_local void @get_volatile
228
+ // LLVM: [[TMP0:%.*]] = alloca ptr, i64 1, align 8
229
+ // LLVM: [[TMP1:%.*]] = load ptr, ptr [[TMP0]], align 8
230
+ // LLVM: [[TMP2:%.*]] = getelementptr %struct.V, ptr [[TMP1]], i32 0, i32 0
231
+ // LLVM: [[TMP3:%.*]] = load volatile i64, ptr [[TMP2]], align 8
232
+ // LLVM: [[TMP4:%.*]] = and i64 [[TMP3]], -1095216660481
233
+ // LLVM: [[TMP5:%.*]] = or i64 [[TMP4]], 12884901888
234
+ // LLVM: store volatile i64 [[TMP5]], ptr [[TMP2]], align 8
235
+
236
+ // OCGC: define dso_local void @get_volatile
237
+ // OCGC: [[TMP0:%.*]] = alloca ptr, align 8
238
+ // OCGC: [[TMP1:%.*]] = load ptr, ptr [[TMP0]], align 8
239
+ // OCGC: [[TMP2:%.*]] = load volatile i64, ptr [[TMP1]], align 4
240
+ // OCGC: [[TMP3:%.*]] = and i64 [[TMP2]], -1095216660481
241
+ // OCGC: [[TMP4:%.*]] = or i64 [[TMP3]], 12884901888
242
+ // OCGC: store volatile i64 [[TMP4]], ptr [[TMP1]], align 4
243
+
216
244
void set_volatile (V * v ) {
217
245
v -> b = 3 ;
218
246
}
0 commit comments