llvm-project/llvm/test/CodeGen/WebAssembly/naked-fn-with-frame-pointer.ll
yonghong-song 0ffe83feac
[SelectionDAG] Not issue TRAP node if naked function (#132147)
In [1], Nikita Popov suggested that during lowering 'unreachable' insn
should not generate extra code for naked functions, and this applies to
all architectures. Note that for naked functions, 'unreachable' insn is
necessary in IR since the basic block needs a terminator to end.

This patch checked whether a function is naked function or not. If it is
a naked function, 'unreachable' insn will not generate ISD::TRAP.

  [1] https://github.com/llvm/llvm-project/pull/131731

Co-authored-by: Yonghong Song <yonghong.song@linux.dev>
2025-03-20 18:18:03 -07:00

36 lines
1.0 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
; RUN: llc < %s -mtriple wasm32 | FileCheck %s -check-prefixes=CHECK-32
; RUN: llc < %s -mtriple wasm64 | FileCheck %s -check-prefixes=CHECK-64
declare dso_local void @main()
define dso_local void @naked() naked "frame-pointer"="all" {
; CHECK-32-LABEL: naked:
; CHECK-32: .functype naked () -> ()
; CHECK-32-NEXT: # %bb.0:
; CHECK-32-NEXT: call main
;
; CHECK-64-LABEL: naked:
; CHECK-64: .functype naked () -> ()
; CHECK-64-NEXT: # %bb.0:
; CHECK-64-NEXT: call main
call void @main()
unreachable
}
define dso_local void @normal() "frame-pointer"="all" {
; CHECK-32-LABEL: normal:
; CHECK-32: .functype normal () -> ()
; CHECK-32-NEXT: # %bb.0:
; CHECK-32-NEXT: call main
; CHECK-32-NEXT: unreachable
;
; CHECK-64-LABEL: normal:
; CHECK-64: .functype normal () -> ()
; CHECK-64-NEXT: # %bb.0:
; CHECK-64-NEXT: call main
; CHECK-64-NEXT: unreachable
call void @main()
unreachable
}