File: catchswitch-phi.ll

package info (click to toggle)
llvm-toolchain-14 1%3A14.0.6-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,496,180 kB
  • sloc: cpp: 5,593,972; ansic: 986,872; asm: 585,869; python: 184,223; objc: 72,530; lisp: 31,119; f90: 27,793; javascript: 9,780; pascal: 9,762; sh: 9,482; perl: 7,468; ml: 5,432; awk: 3,523; makefile: 2,538; xml: 953; cs: 573; fortran: 567
file content (53 lines) | stat: -rw-r--r-- 1,886 bytes parent folder | download | duplicates (6)
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
; RUN: opt < %s -instcombine -S | FileCheck %s

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

%struct.quux = type { i32 }
%struct.blam = type <{ %struct.quux }>

declare void @foo()
declare void @bar(%struct.quux*)
declare i32 @__gxx_wasm_personality_v0(...)

define void @test() personality i8* bitcast (i32 (...)* @__gxx_wasm_personality_v0 to i8*) {
bb:
  %tmp0 = alloca %struct.blam, align 4
  br i1 undef, label %bb1, label %bb2

bb1:                                              ; preds = %bb
  %tmp1 = getelementptr inbounds %struct.blam, %struct.blam* %tmp0, i32 0, i32 0
  invoke void @foo()
          to label %bb3 unwind label %bb4

bb2:                                              ; preds = %bb
  %tmp2 = getelementptr inbounds %struct.blam, %struct.blam* %tmp0, i32 0, i32 0
  invoke void @foo()
          to label %bb3 unwind label %bb4

bb3:                                              ; preds = %bb2, %bb1
  unreachable

bb4:                                              ; preds = %bb2, %bb1
  ; This PHI should not be combined into a non-PHI instruction, because
  ; catchswitch BB cannot have any non-PHI instruction other than catchswitch
  ; itself.
  ; CHECK: bb4:
  ; CHECK-NEXT: phi
  ; CHECK-NEXT: catchswitch
  %tmp3 = phi %struct.quux* [ %tmp1, %bb1 ], [ %tmp2, %bb2 ]
  %tmp4 = catchswitch within none [label %bb5] unwind label %bb7

bb5:                                              ; preds = %bb4
  %tmp5 = catchpad within %tmp4 [i8* null]
  invoke void @foo() [ "funclet"(token %tmp5) ]
          to label %bb6 unwind label %bb7

bb6:                                              ; preds = %bb5
  unreachable

bb7:                                              ; preds = %bb5, %bb4
  %tmp6 = cleanuppad within none []
  call void @bar(%struct.quux* %tmp3) [ "funclet"(token %tmp6) ]
  unreachable
}