1; RUN: llc < %s -asm-verbose=false -verify-machineinstrs | FileCheck %s 2 3; Test lowering of __builtin_debugtrap in cases where lowering it via 4; the normal UNREACHABLE instruction would yield invalid 5; MachineFunctions. 6 7target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" 8target triple = "wasm32" 9 10declare void @llvm.debugtrap() 11 12; CHECK-LABEL: foo: 13; CHECK-NEXT: .functype foo (i32) -> () 14; CHECK-NEXT: .LBB0_1: 15; CHECK-NEXT: loop 16; CHECK-NEXT: unreachable 17; CHECK-NEXT: i32.const 0 18; CHECK-NEXT: br_if 0 19; CHECK-NEXT: end_loop 20; CHECK-NEXT: end_function 21define void @foo(i32 %g) { 22entry: 23 br label %for.body 24 25for.body: 26 call void @llvm.debugtrap() 27 %exitcond = icmp eq i32 undef, %g 28 br i1 %exitcond, label %for.cond.cleanup, label %for.body 29 30for.cond.cleanup: 31 ret void 32} 33 34; CHECK-LABEL: middle_of_block: 35; CHECK-NEXT: .functype middle_of_block (i32, i32) -> (i32) 36; CHECK-NEXT: unreachable 37; CHECK-NEXT: local.get 0 38; CHECK-NEXT: local.get 1 39; CHECK-NEXT: i32.add 40; CHECK-NEXT: end_function 41define i32 @middle_of_block(i32 %x, i32 %y) { 42 %r = add i32 %x, %y 43 call void @llvm.debugtrap() 44 ret i32 %r 45} 46 47; CHECK-LABEL: really_middle_of_block: 48; CHECK-NEXT: .functype really_middle_of_block () -> (i32) 49; CHECK-NEXT: call bar 50; CHECK-NEXT: drop 51; CHECK-NEXT: unreachable 52; CHECK-NEXT: call bar 53; CHECK-NEXT: end_function 54declare i32 @bar() 55define i32 @really_middle_of_block() { 56 %x = call i32 @bar() 57 call void @llvm.debugtrap() 58 %r = call i32 @bar() 59 ret i32 %r 60} 61