xref: /llvm-project/llvm/test/Feature/memorymarkers.ll (revision 1842a2909e80da9432c5d79a95ec2c331bd99744)
1; RUN: llvm-as -disable-output < %s
2
3%"struct.std::pair<int,int>" = type { i32, i32 }
4
5declare void @_Z3barRKi(ptr)
6
7declare void @llvm.lifetime.start(i64, ptr nocapture) nounwind
8declare void @llvm.lifetime.end(i64, ptr nocapture) nounwind
9declare ptr @llvm.invariant.start.p0(i64, ptr nocapture) readonly nounwind
10declare void @llvm.invariant.end.p0(ptr, i64, ptr nocapture) nounwind
11
12define i32 @_Z4foo2v() nounwind {
13entry:
14  %x = alloca %"struct.std::pair<int,int>"
15
16  ;; Constructor starts here (this isn't needed since it is immediately
17  ;; preceded by an alloca, but shown for completeness).
18  call void @llvm.lifetime.start(i64 8, ptr %x)
19
20  %0 = getelementptr %"struct.std::pair<int,int>", ptr %x, i32 0, i32 0
21  store i32 4, ptr %0, align 8
22  %1 = getelementptr %"struct.std::pair<int,int>", ptr %x, i32 0, i32 1
23  store i32 5, ptr %1, align 4
24
25  ;; Constructor has finished here.
26  %inv = call ptr @llvm.invariant.start.p0(i64 8, ptr %x)
27  call void @_Z3barRKi(ptr %0) nounwind
28  %2 = load i32, ptr %0, align 8
29
30  ;; Destructor is run here.
31  call void @llvm.invariant.end.p0(ptr %inv, i64 8, ptr %x)
32  ;; Destructor is done here.
33  call void @llvm.lifetime.end(i64 8, ptr %x)
34  ret i32 %2
35}
36