File: coro-frame-reuse-alloca-04.ll

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (74 lines) | stat: -rw-r--r-- 2,995 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
; Tests that variables of different type with incompatible alignment in a Corotuine whose lifetime 
; range is not overlapping each other should not re-use the same slot in Coroutine frame. 
; RUN: opt < %s -passes='cgscc(coro-split<reuse-storage>),simplifycfg,early-cse' -S | FileCheck %s
%"struct.task::promise_type" = type { i8 }
%struct.awaitable = type { i8 }
%struct.big_structure = type { [500 x i8] }
%struct.big_structure.2 = type { [300 x i8] }
declare ptr @malloc(i64)
declare void @consume(ptr)
declare void @consume.2(ptr)
define void @a(i1 zeroext %cond) presplitcoroutine {
entry:
  %__promise = alloca %"struct.task::promise_type", align 1
  %a = alloca %struct.big_structure, align 1
  %ref.tmp7 = alloca %struct.awaitable, align 1
  %b = alloca %struct.big_structure.2, align 32
  %ref.tmp18 = alloca %struct.awaitable, align 1
  %0 = call token @llvm.coro.id(i32 16, ptr nonnull %__promise, ptr @a, ptr null)
  br label %init.ready
init.ready:
  %1 = call noalias nonnull ptr @llvm.coro.begin(token %0, ptr null)
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %__promise)
  br i1 %cond, label %if.then, label %if.else
if.then:
  call void @llvm.lifetime.start.p0(i64 500, ptr nonnull %a)
  call void @consume(ptr nonnull %a)
  %save = call token @llvm.coro.save(ptr null)
  %suspend = call i8 @llvm.coro.suspend(token %save, i1 false)
  switch i8 %suspend, label %coro.ret [
    i8 0, label %await.ready
    i8 1, label %cleanup1
  ]
await.ready:
  call void @llvm.lifetime.end.p0(i64 500, ptr nonnull %a)
  br label %cleanup1
if.else:
  call void @llvm.lifetime.start.p0(i64 300, ptr nonnull %b)
  call void @consume.2(ptr nonnull %b)
  %save2 = call token @llvm.coro.save(ptr null)
  %suspend2 = call i8 @llvm.coro.suspend(token %save2, i1 false)
  switch i8 %suspend2, label %coro.ret [
    i8 0, label %await2.ready
    i8 1, label %cleanup2
  ]
await2.ready:
  call void @llvm.lifetime.end.p0(i64 300, ptr nonnull %b)
  br label %cleanup2
cleanup1:
  call void @llvm.lifetime.end.p0(i64 500, ptr nonnull %a)
  br label %cleanup
cleanup2:
  call void @llvm.lifetime.end.p0(i64 300, ptr nonnull %b)
  br label %cleanup
cleanup:
  call ptr @llvm.coro.free(token %0, ptr %1)
  br label %coro.ret
coro.ret:
  call i1 @llvm.coro.end(ptr null, i1 false)
  ret void
}
; CHECK:       %a.Frame = type { ptr, ptr, %"struct.task::promise_type", %struct.big_structure, i1, [26 x i8], %struct.big_structure.2 }
; CHECK-LABEL: @a.resume(

declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr)
declare i1 @llvm.coro.alloc(token) #3
declare i64 @llvm.coro.size.i64() #5
declare ptr @llvm.coro.begin(token, ptr writeonly) #3
declare token @llvm.coro.save(ptr) #3
declare ptr @llvm.coro.frame() #5
declare i8 @llvm.coro.suspend(token, i1) #3
declare ptr @llvm.coro.free(token, ptr nocapture readonly) #2
declare i1 @llvm.coro.end(ptr, i1) #3
declare void @llvm.lifetime.start.p0(i64, ptr nocapture) #4
declare void @llvm.lifetime.end.p0(i64, ptr nocapture) #4