-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[AArch64][BTI] Add BTI at EH entries. #155308
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
Merged
+167
−20
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | ||
| ; RUN: llc -mtriple=aarch64-unknown-linux-gnu %s -o - | FileCheck %s | ||
|
|
||
| ; Purpose: With BTI enabled, the landing pad (%lpad) begins with an EH_LABEL and the | ||
| ; first *executed* instruction is `bti j`. (BTI is inserted *after* the EH label and meta.) | ||
|
|
||
| declare i32 @__gxx_personality_v0(...) | ||
| declare void @may_throw() | ||
|
|
||
| define void @test() #0 personality ptr @__gxx_personality_v0 { | ||
| ; CHECK-LABEL: test: | ||
| ; CHECK: .Lfunc_begin0: | ||
| ; CHECK-NEXT: .cfi_startproc | ||
| ; CHECK-NEXT: .cfi_personality 156, DW.ref.__gxx_personality_v0 | ||
| ; CHECK-NEXT: .cfi_lsda 28, .Lexception0 | ||
| ; CHECK-NEXT: // %bb.0: // %entry | ||
| ; CHECK-NEXT: bti c | ||
| ; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill | ||
| ; CHECK-NEXT: .cfi_def_cfa_offset 16 | ||
| ; CHECK-NEXT: .cfi_offset w30, -16 | ||
| ; CHECK-NEXT: .Ltmp0: // EH_LABEL | ||
| ; CHECK-NEXT: bl may_throw | ||
| ; CHECK-NEXT: .Ltmp1: // EH_LABEL | ||
| ; CHECK-NEXT: // %bb.1: // %common.ret | ||
| ; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload | ||
| ; CHECK-NEXT: ret | ||
| ; CHECK-NEXT: .LBB0_2: // %lpad | ||
| ; CHECK-NEXT: .Ltmp2: // EH_LABEL | ||
| ; CHECK-NEXT: bti j | ||
| ; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload | ||
| ; CHECK-NEXT: ret | ||
| entry: | ||
| invoke void @may_throw() | ||
| to label %ret unwind label %lpad | ||
|
|
||
| lpad: | ||
| landingpad { ptr, i32 } cleanup | ||
| ret void | ||
|
|
||
| ret: | ||
| ret void | ||
| } | ||
|
|
||
| attributes #0 = { noinline "branch-target-enforcement"="true" "target-features"="+bti" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | ||
| ; RUN: llc -mtriple=aarch64-windows -mattr=+bti -o - %s | FileCheck %s | ||
|
|
||
| declare i32 @__CxxFrameHandler3(...) | ||
| declare void @may_throw() | ||
|
|
||
| ; Purpose: For WinEH funclets, entry is call-like: accept `bti c` / `hint #34` or a PAC prologue. | ||
|
|
||
| define dso_local void @wineh_funclet() #0 personality ptr @__CxxFrameHandler3 { | ||
| ; CHECK-LABEL: wineh_funclet: | ||
| ; CHECK: .Lfunc_begin0: | ||
| ; CHECK-NEXT: .seh_proc wineh_funclet | ||
| ; CHECK-NEXT: .seh_handler __CxxFrameHandler3, @unwind, @except | ||
| ; CHECK-NEXT: // %bb.0: // %entry | ||
| ; CHECK-NEXT: bti c | ||
| ; CHECK-NEXT: .seh_nop | ||
| ; CHECK-NEXT: stp x29, x30, [sp, #-32]! // 16-byte Folded Spill | ||
| ; CHECK-NEXT: .seh_save_fplr_x 32 | ||
| ; CHECK-NEXT: mov x29, sp | ||
| ; CHECK-NEXT: .seh_set_fp | ||
| ; CHECK-NEXT: .seh_endprologue | ||
| ; CHECK-NEXT: mov x0, #-2 // =0xfffffffffffffffe | ||
| ; CHECK-NEXT: stur x0, [x29, #16] | ||
| ; CHECK-NEXT: .Ltmp0: // EH_LABEL | ||
| ; CHECK-NEXT: bl may_throw | ||
| ; CHECK-NEXT: .Ltmp1: // EH_LABEL | ||
| ; CHECK-NEXT: .LBB0_1: // Block address taken | ||
| ; CHECK-NEXT: // %try.cont | ||
| ; CHECK-NEXT: $ehgcr_0_1: | ||
| ; CHECK-NEXT: bti j | ||
| ; CHECK-NEXT: .seh_startepilogue | ||
| ; CHECK-NEXT: ldp x29, x30, [sp], #32 // 16-byte Folded Reload | ||
| ; CHECK-NEXT: .seh_save_fplr_x 32 | ||
| ; CHECK-NEXT: .seh_endepilogue | ||
| ; CHECK-NEXT: ret | ||
| ; CHECK-NEXT: .seh_endfunclet | ||
| ; CHECK-NEXT: .seh_handlerdata | ||
| ; CHECK-NEXT: .word $cppxdata$wineh_funclet@IMGREL | ||
| ; CHECK-NEXT: .text | ||
| ; CHECK-NEXT: .seh_endproc | ||
| ; CHECK-NEXT: .def "?catch$2@?0?wineh_funclet@4HA"; | ||
| ; CHECK-NEXT: .scl 3; | ||
| ; CHECK-NEXT: .type 32; | ||
| ; CHECK-NEXT: .endef | ||
| ; CHECK-NEXT: .p2align 2 | ||
| ; CHECK-NEXT: "?catch$2@?0?wineh_funclet@4HA": | ||
| ; CHECK-NEXT: .seh_proc "?catch$2@?0?wineh_funclet@4HA" | ||
| ; CHECK-NEXT: .seh_handler __CxxFrameHandler3, @unwind, @except | ||
| ; CHECK-NEXT: .LBB0_2: // %catch | ||
| ; CHECK-NEXT: bti c | ||
| ; CHECK-NEXT: .seh_nop | ||
| ; CHECK-NEXT: stp x29, x30, [sp, #-16]! // 16-byte Folded Spill | ||
| ; CHECK-NEXT: .seh_save_fplr_x 16 | ||
| ; CHECK-NEXT: .seh_endprologue | ||
| ; CHECK-NEXT: bl may_throw | ||
| ; CHECK-NEXT: adrp x0, .LBB0_1 | ||
| ; CHECK-NEXT: add x0, x0, .LBB0_1 | ||
| ; CHECK-NEXT: .seh_startepilogue | ||
| ; CHECK-NEXT: ldp x29, x30, [sp], #16 // 16-byte Folded Reload | ||
| ; CHECK-NEXT: .seh_save_fplr_x 16 | ||
| ; CHECK-NEXT: .seh_endepilogue | ||
| ; CHECK-NEXT: ret | ||
| entry: | ||
| invoke void @may_throw() | ||
| to label %try.cont unwind label %catch.dispatch | ||
|
|
||
| catch.dispatch: | ||
| %cs = catchswitch within none [label %catch] unwind to caller | ||
|
|
||
| catch: | ||
| %cp = catchpad within %cs [ptr null, i32 0, ptr null] | ||
| call void @may_throw() ["funclet"(token %cp)] | ||
| catchret from %cp to label %try.cont | ||
|
|
||
| try.cont: | ||
| ret void | ||
| } | ||
|
|
||
| attributes #0 = { noinline "branch-target-enforcement"="true" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.