File: irreducible-cfg.mir

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (85 lines) | stat: -rw-r--r-- 2,670 bytes parent folder | download | duplicates (13)
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
75
76
77
78
79
80
81
82
83
84
85
# RUN: llc -mtriple=wasm32-unknown-unknown -run-pass wasm-fix-irreducible-control-flow %s -o - | FileCheck %s

# This tests if we correctly create at most 2 routing blocks per entry block,
# and also whether those routing blocks are generated in the correct place. If
# one of the predecessor is the layout predecessor of an entry, a routing block
# for the entry should be generated right after the layout predecessor.

--- |
  target triple = "wasm32-unknown-unknown"

  define void @test0() {
  pred0:
    ret void
  pred1:
    ret void
  entry0:
    ret void
  entry1:
    ret void
  }
...

---
# CHECK-LABEL: test0
name: test0
liveins:
  - { reg: '$arguments' }
body: |
  bb.0.pred0:
    successors: %bb.1, %bb.2
    liveins: $arguments
    %0:i32 = CONST_I32 100, implicit-def $arguments
    BR_IF %bb.2, %0:i32, implicit-def $arguments
  ; CHECK: bb.0.pred0:
    ; CHECK:      %1:i32 = IMPLICIT_DEF
    ; CHECK-NEXT: %0:i32 = IMPLICIT_DEF
    ; CHECK:      BR_IF %bb.2, %0, implicit-def $arguments

  bb.1.pred1:
  ; predecessors: %bb.1
    successors: %bb.2, %bb.3
    BR_IF %bb.3, %0:i32, implicit-def $arguments
  ; CHECK: bb.1.pred1:
    ; CHECK:      BR_IF %bb.7, %0, implicit-def $arguments
    ; This falls through to bb.2, so we don't need an additional BR here
    ; CHECK-NOT:  BR

  ; Routing block for entry0, when predecessor is outside the loop
  ; This routing block is shared between the two predecessors: pred0 and pred1.
  ; CHECK: bb.2:
    ; CHECK:      %1:i32 = CONST_I32 0, implicit-def $arguments
    ; CHECK-NEXT: BR %bb.6, implicit-def $arguments

  bb.2.entry0:
  ; predecessors: %bb.0, %bb.1, %bb.1
    successors: %bb.3
    BR %bb.3, implicit-def $arguments
  ; CHECK: bb.3.entry0:
    ; CHECK:      BR %bb.4, implicit-def $arguments

  ; Routing block for entry1, when predecessor is inside the loop
  ; CHECK: bb.4:
    ; CHECK:      %1:i32 = CONST_I32 1, implicit-def $arguments
    ; CHECK-NEXT: BR %bb.6, implicit-def $arguments

  bb.3.entry1:
  ; predecessors: %bb.1, %bb.2
    successors: %bb.2
    BR %bb.2, implicit-def $arguments
  ; CHECK: bb.5.entry1:
    ; CHECK:      BR %bb.8, implicit-def $arguments

  ; Dispatch block
  ; CHECK: bb.6:
    ; CHECK:      BR_TABLE_I32 %1, %bb.3, %bb.5, %bb.5, implicit-def $arguments

  ; Routing block for entry1, when predecessor is outside the loop
  ; CHECK: bb.7:
    ; CHECK:      %1:i32 = CONST_I32 1, implicit-def $arguments
    ; CHECK-NEXT: BR %bb.6, implicit-def $arguments

  ; Routing block for entry0, when predecessor is inside the loop
  ; CHECK: bb.8:
    ; CHECK:      %1:i32 = CONST_I32 0, implicit-def $arguments
    ; CHECK-NEXT: BR %bb.6, implicit-def $arguments