File: phi-catchswitch.ll

package info (click to toggle)
llvm-toolchain-17 1%3A17.0.6-22
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,799,624 kB
  • sloc: cpp: 6,428,607; ansic: 1,383,196; asm: 793,408; python: 223,504; objc: 75,364; f90: 60,502; lisp: 33,869; pascal: 15,282; sh: 9,684; perl: 7,453; ml: 4,937; awk: 3,523; makefile: 2,889; javascript: 2,149; xml: 888; fortran: 619; cs: 573
file content (69 lines) | stat: -rw-r--r-- 2,896 bytes parent folder | download | duplicates (12)
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
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -passes='sroa<preserve-cfg>' -S | FileCheck %s --check-prefixes=CHECK,CHECK-PRESERVE-CFG
; RUN: opt < %s -passes='sroa<modify-cfg>' -S | FileCheck %s --check-prefixes=CHECK,CHECK-MODIFY-CFG

target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
target triple = "wasm32-unknown-unknown"

%struct.foo = type { i32 }
declare i32 @__gxx_wasm_personality_v0(...)
declare void @foo()

; Tests if the SROA pass correctly bails out on rewriting PHIs in a catchswitch
; BB.
define void @test_phi_catchswitch() personality ptr @__gxx_wasm_personality_v0 {
; CHECK-LABEL: @test_phi_catchswitch(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[TMP:%.*]] = alloca [[STRUCT_FOO:%.*]], align 4
; CHECK-NEXT:    invoke void @foo()
; CHECK-NEXT:    to label [[BB3:%.*]] unwind label [[BB10:%.*]]
; CHECK:       bb3:
; CHECK-NEXT:    invoke void @foo()
; CHECK-NEXT:    to label [[BB9:%.*]] unwind label [[CATCH_DISPATCH:%.*]]
; CHECK:       catch.dispatch:
; CHECK-NEXT:    [[TMP5:%.*]] = phi ptr [ [[TMP]], [[BB3]] ]
; CHECK-NEXT:    [[TMP6:%.*]] = catchswitch within none [label %catch.start] unwind label [[BB10]]
; CHECK:       catch.start:
; CHECK-NEXT:    [[TMP8:%.*]] = catchpad within [[TMP6]] [ptr null]
; CHECK-NEXT:    unreachable
; CHECK:       bb9:
; CHECK-NEXT:    unreachable
; CHECK:       bb10:
; CHECK-NEXT:    [[TMP11:%.*]] = phi ptr [ [[TMP]], [[ENTRY:%.*]] ], [ [[TMP5]], [[CATCH_DISPATCH]] ]
; CHECK-NEXT:    [[TMP12:%.*]] = cleanuppad within none []
; CHECK-NEXT:    store i32 0, ptr [[TMP11]], align 4
; CHECK-NEXT:    unreachable
;
entry:
  %tmp = alloca %struct.foo, align 4
  invoke void @foo()
  to label %bb3 unwind label %bb10

bb3:                                              ; preds = %entry
  invoke void @foo()
  to label %bb9 unwind label %catch.dispatch

catch.dispatch:                                   ; preds = %bb3
  ; While rewriting the alloca in the entry BB, the SROA pass tries to insert a
  ; non-PHI instruction in this BB by calling getFirstInsertionPt(), which is
  ; not possible in a catchswitch BB. This test checks if we correctly bail out
  ; on these cases.
  %tmp5 = phi ptr [ %tmp, %bb3 ]
  %tmp6 = catchswitch within none [label %catch.start] unwind label %bb10

catch.start:                                      ; preds = %catch.dispatch
  %tmp8 = catchpad within %tmp6 [ptr null]
  unreachable

bb9:                                              ; preds = %bb3
  unreachable

bb10:                                             ; preds = %catch.dispatch, %entry
  %tmp11 = phi ptr [ %tmp, %entry ], [ %tmp5, %catch.dispatch ]
  %tmp12 = cleanuppad within none []
  store i32 0, ptr %tmp11, align 4
  unreachable
}
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
; CHECK-MODIFY-CFG: {{.*}}
; CHECK-PRESERVE-CFG: {{.*}}