Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command line option --no-trap-after-noreturn #67051

Merged
merged 2 commits into from
Sep 22, 2023
Merged

Conversation

majaha
Copy link
Contributor

@majaha majaha commented Sep 21, 2023

Add the command line option --no-trap-after-noreturn, which exposes the pre-existing TargetOption NoTrapAfterNoreturn.

This pull request was split off from this one: #65876

Add the command line option --no-trap-after-noreturn, which
exposes the pre-existing TargetOption NoTrapAfterNoreturn.
Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is what I had in mind.

@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please use update_llc_test_checks.py for this test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

; NTANR-NOT: .inst.n 0xdefe
;
call void @no_return()
unreachable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest adding another block to this function with a non-noreturn call.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@majaha
Copy link
Contributor Author

majaha commented Sep 21, 2023

The CI on Windows seems to be failing because of issues with anti-virus software, I don't think it's my fault.

Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nikic nikic merged commit 64d1cea into llvm:main Sep 22, 2023
1 of 2 checks passed
@majaha majaha deleted the ntanr_flag branch September 22, 2023 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants