[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:50:13 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
----------------
majaha wrote:

I used it to generate the test originally, but had to hand-edit it because it produced this output:
```
...
define void @test_ntanr_noreturn() {
; TRAP_UNREACHABLE-LABEL: test_ntanr_noreturn:
; TRAP_UNREACHABLE:       @ %bb.0:
; TRAP_UNREACHABLE-NEXT:    push {r7, lr}
; TRAP_UNREACHABLE-NEXT:    bl no_return
; TRAP_UNREACHABLE-NEXT:    .inst.n 0xdefe
;
; NTANR-LABEL: test_ntanr_noreturn:
; NTANR:       @ %bb.0:
; NTANR-NEXT:    push {r7, lr}
; NTANR-NEXT:    bl no_return
  call void @no_return()
  unreachable
}
```
This is a bad test, because it wouldn't reject when --no-trap-after-noreturn doesn't do its job and a trap is still emitted at the end.

This was something that I came across in the other pull request too: update_llc_test_checks.py isn't very good at checking for extraneous instructions at the end of functions.

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


More information about the llvm-commits mailing list