File: sink-with-coroutine.ll

package info (click to toggle)
llvm-toolchain-13 1%3A13.0.1-11
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,418,840 kB
  • sloc: cpp: 5,290,826; ansic: 996,570; asm: 544,593; python: 188,212; objc: 72,027; lisp: 30,291; f90: 25,395; sh: 24,898; javascript: 9,780; pascal: 9,398; perl: 7,484; ml: 5,432; awk: 3,523; makefile: 2,913; xml: 953; cs: 573; fortran: 539
file content (52 lines) | stat: -rw-r--r-- 1,548 bytes parent folder | download | duplicates (7)
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
; Verifies that LICM is disabled for loops that contains coro.suspend.
; RUN: opt -S < %s -passes=licm | FileCheck %s

define i64 @licm(i64 %n) #0 {
; CHECK-LABEL: @licm(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[P:%.*]] = alloca i64, align 8
; CHECK-NEXT:    br label [[BB0:%.*]]
; CHECK:       bb0:
; CHECK-NEXT:    br label [[LOOP:%.*]]
; CHECK:       loop:
; CHECK-NEXT:    [[I:%.*]] = phi i64 [ 0, [[BB0]] ], [ [[T5:%.*]], [[AWAIT_READY:%.*]] ]
; CHECK-NEXT:    [[T5]] = add i64 [[I]], 1
; CHECK-NEXT:    [[SUSPEND:%.*]] = call i8 @llvm.coro.suspend(token none, i1 false)
; CHECK-NEXT:    switch i8 [[SUSPEND]], label [[BB2:%.*]] [
; CHECK-NEXT:    i8 0, label [[AWAIT_READY]]
; CHECK-NEXT:    ]
; CHECK:       await.ready:
; CHECK-NEXT:    store i64 1, i64* [[P]], align 4
; CHECK-NEXT:    [[T6:%.*]] = icmp ult i64 [[T5]], [[N:%.*]]
; CHECK-NEXT:    br i1 [[T6]], label [[LOOP]], label [[BB2]]
; CHECK:       bb2:
; CHECK-NEXT:    [[RES:%.*]] = call i1 @llvm.coro.end(i8* null, i1 false)
; CHECK-NEXT:    ret i64 0
;
entry:
  %p = alloca i64
  br label %bb0

bb0:
  br label %loop

loop:
  %i = phi i64 [ 0, %bb0 ], [ %t5, %await.ready ]
  %t5 = add i64 %i, 1
  %suspend = call i8 @llvm.coro.suspend(token none, i1 false)
  switch i8 %suspend, label %bb2 [
  i8 0, label %await.ready
  ]

await.ready:
  store i64 1, i64* %p
  %t6 = icmp ult i64 %t5, %n
  br i1 %t6, label %loop, label %bb2

bb2:
  %res = call i1 @llvm.coro.end(i8* null, i1 false)
  ret i64 0
}

declare i8  @llvm.coro.suspend(token, i1)
declare i1  @llvm.coro.end(i8*, i1)