[llvm] Add command line option --no-trap-after-noreturn (PR #67051)

Matt Harding via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 21 15:54:56 PDT 2023


================
@@ -1,8 +1,25 @@
-; RUN: llc -mtriple=thumbv7 -trap-unreachable < %s | FileCheck %s
-; CHECK: .inst.n 0xdefe
+; RUN: llc -mtriple=thumbv7 -trap-unreachable < %s | FileCheck %s --check-prefixes CHECK,TRAP_UNREACHABLE
+; RUN: llc -mtriple=thumbv7 -trap-unreachable -no-trap-after-noreturn < %s | FileCheck %s --check-prefixes CHECK,NTANR
 
-define void @test() #0 {
+define void @test_trap_unreachable() #0 {
+; CHECK-LABEL: test_trap_unreachable:
+; CHECK:       @ %bb.0:
+; CHECK-NEXT:    .inst.n 0xdefe
   unreachable
 }
 
 attributes #0 = { nounwind }
+
+declare void @no_return() noreturn
+
+define void @test_ntanr() {
+; CHECK-LABEL:           test_ntanr:
+; CHECK:                 @ %bb.0:
+; CHECK-NEXT:              push {r7, lr}
+; CHECK-NEXT:              bl no_return
+; TRAP_UNREACHABLE-NEXT:   .inst.n 0xdefe
+; NTANR-NOT:               .inst.n 0xdefe
+;
+  call void @no_return()
+  unreachable
----------------
majaha wrote:

I've added a new function instead, because I thought that was simpler. It makes sure --no-trap-after-noreturn isn't removing traps after normal function call, hopefully that's what you were getting at.

https://github.com/llvm/llvm-project/pull/67051


More information about the llvm-commits mailing list