blob: 9dcd15676a497cdaa8c01acfe86786241b0f4fc9 (
plain)
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
|
; RUN: llc < %s -asm-verbose=false -verify-machineinstrs | FileCheck %s
; Test lowering of __builtin_debugtrap in cases where lowering it via
; the normal UNREACHABLE instruction would yield invalid
; MachineFunctions.
target triple = "wasm32"
declare void @llvm.debugtrap()
; CHECK-LABEL: foo:
; CHECK-NEXT: .functype foo (i32) -> ()
; CHECK-NEXT: .LBB0_1:
; CHECK-NEXT: loop
; CHECK-NEXT: unreachable
; CHECK-NEXT: i32.const 0
; CHECK-NEXT: br_if 0
; CHECK-NEXT: end_loop
; CHECK-NEXT: end_function
define void @foo(i32 %g) {
entry:
br label %for.body
for.body:
call void @llvm.debugtrap()
%exitcond = icmp eq i32 undef, %g
br i1 %exitcond, label %for.cond.cleanup, label %for.body
for.cond.cleanup:
ret void
}
; CHECK-LABEL: middle_of_block:
; CHECK-NEXT: .functype middle_of_block (i32, i32) -> (i32)
; CHECK-NEXT: unreachable
; CHECK-NEXT: local.get 0
; CHECK-NEXT: local.get 1
; CHECK-NEXT: i32.add
; CHECK-NEXT: end_function
define i32 @middle_of_block(i32 %x, i32 %y) {
%r = add i32 %x, %y
call void @llvm.debugtrap()
ret i32 %r
}
; CHECK-LABEL: really_middle_of_block:
; CHECK-NEXT: .functype really_middle_of_block () -> (i32)
; CHECK-NEXT: call bar
; CHECK-NEXT: drop
; CHECK-NEXT: unreachable
; CHECK-NEXT: call bar
; CHECK-NEXT: end_function
declare i32 @bar()
define i32 @really_middle_of_block() {
%x = call i32 @bar()
call void @llvm.debugtrap()
%r = call i32 @bar()
ret i32 %r
}
|