-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[BOLT] Extend Inliner to work on functions with Pointer Authentication #162458
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
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1c5251f
[BOLT] Extend Inliner to work on functions with Pointer Autentication
bgergely0 754a053
[BOLT] Fix when inlining into a context with a tailcall
bgergely0 d0943f1
[BOLT] Fix: copy operands of MCInst in createMatchingAuth
bgergely0 267c93a
[BOLT] Add unittest for inliner using retaasppc <label>
bgergely0 48069be
Fix comment
bgergely0 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
Some comments aren't visible on the classic Files Changed page.
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
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,45 @@ | ||
| # This test checks that inlining functions with fused pointer-auth-and-return | ||
| # instructions is properly handled by BOLT. | ||
|
|
||
| # REQUIRES: system-linux | ||
|
|
||
| # RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown -mattr=+v8.3a %s -o %t.o | ||
| # RUN: %clang %cflags -O0 %t.o -o %t.exe -Wl,-q | ||
| # RUN: llvm-bolt --inline-all --print-inline --print-only=_Z3barP1A \ | ||
| # RUN: %t.exe -o %t.bolt | FileCheck %s | ||
|
|
||
| # CHECK: BOLT-INFO: inlined 0 calls at 1 call sites in 2 iteration(s). Change in binary size: 8 bytes. | ||
| # CHECK: Binary Function "_Z3barP1A" after inlining { | ||
| # CHECK-NOT: bl _Z3fooP1A | ||
| # CHECK: ldr x8, [x0] | ||
| # CHECK-NEXT: ldr w0, [x8] | ||
| # CHECK-NEXT: autiasp | ||
|
|
||
| .text | ||
| .globl _Z3fooP1A | ||
| .type _Z3fooP1A,@function | ||
| _Z3fooP1A: | ||
| paciasp | ||
| ldr x8, [x0] | ||
| ldr w0, [x8] | ||
| retaa | ||
| .size _Z3fooP1A, .-_Z3fooP1A | ||
|
|
||
| .globl _Z3barP1A | ||
| .type _Z3barP1A,@function | ||
| _Z3barP1A: | ||
| stp x29, x30, [sp, #-16]! | ||
| mov x29, sp | ||
| bl _Z3fooP1A | ||
| mul w0, w0, w0 | ||
| ldp x29, x30, [sp], #16 | ||
| ret | ||
| .size _Z3barP1A, .-_Z3barP1A | ||
|
|
||
| .globl main | ||
| .p2align 2 | ||
| .type main,@function | ||
| main: | ||
| mov w0, wzr | ||
| ret | ||
| .size main, .-main |
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,46 @@ | ||
| # This test checks that inlining functions with fused pointer-auth-and-return | ||
| # instructions into a location with a tailcall is properly handled by BOLT. | ||
| # Because _Z3barP1A ends in a tailcall, we don't remove the return instruction | ||
| # from the inlined block. Therefore, we should see a retaa, and not an autiasp. | ||
|
|
||
| # REQUIRES: system-linux | ||
|
|
||
| # RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown -mattr=+v8.3a %s -o %t.o | ||
| # RUN: %clang %cflags -O0 %t.o -o %t.exe -Wl,-q | ||
| # RUN: llvm-bolt --inline-all --print-inline --print-only=_Z3barP1A \ | ||
| # RUN: %t.exe -o %t.bolt | FileCheck %s | ||
|
|
||
| # CHECK: BOLT-INFO: inlined 0 calls at 1 call sites in 2 iteration(s). Change in binary size: 12 bytes. | ||
| # CHECK: Binary Function "_Z3barP1A" after inlining { | ||
| # CHECK-NOT: bl _Z3fooP1A | ||
| # CHECK: mov x29, sp | ||
| # CHECK-NEXT: paciasp | ||
| # CHECK-NEXT: ldr x8, [x0] | ||
| # CHECK-NEXT: ldr w0, [x8] | ||
| # CHECK-NEXT: retaa | ||
|
|
||
| .text | ||
| .globl _Z3fooP1A | ||
| .type _Z3fooP1A,@function | ||
| _Z3fooP1A: | ||
| paciasp | ||
| ldr x8, [x0] | ||
| ldr w0, [x8] | ||
| retaa | ||
| .size _Z3fooP1A, .-_Z3fooP1A | ||
|
|
||
| .globl _Z3barP1A | ||
| .type _Z3barP1A,@function | ||
| _Z3barP1A: | ||
| stp x29, x30, [sp, #-16]! | ||
| mov x29, sp | ||
| b _Z3fooP1A // tailcall | ||
| .size _Z3barP1A, .-_Z3barP1A | ||
|
|
||
| .globl main | ||
| .p2align 2 | ||
| .type main,@function | ||
| main: | ||
| mov w0, wzr | ||
| ret | ||
| .size main, .-main |
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,61 @@ | ||
| # This test checks that inlining functions with the pauth-lr variants of | ||
| # fused pointer-auth-and-return instructions is properly handled by BOLT. | ||
|
|
||
| # REQUIRES: system-linux | ||
|
|
||
| # RUN: %clang %cflags -march=armv9.5-a+pauth-lr -O0 %s -o %t.exe -Wl,-q | ||
| # RUN: llvm-bolt --inline-all --print-inline --print-only=_Z3barP1A \ | ||
| # RUN: %t.exe -o %t.bolt | FileCheck %s | ||
|
|
||
| # CHECK: BOLT-INFO: inlined 0 calls at 2 call sites in 2 iteration(s). Change in binary size: 16 bytes. | ||
| # CHECK: Binary Function "_Z3barP1A" after inlining { | ||
| # CHECK-NOT: bl _Z3fooP1A | ||
| # CHECK: paciasppc | ||
| # CHECK-NEXT: ldr x8, [x0] | ||
| # CHECK-NEXT: ldr w0, [x8] | ||
| # CHECK-NEXT: autiasppcr x28 | ||
| # CHECK-NEXT: paciasppc | ||
| # CHECK-NEXT: ldr x7, [x0] | ||
| # CHECK-NEXT: ldr w0, [x7] | ||
| # CHECK-NEXT: autiasppc _Z3bazP1A | ||
|
|
||
| .text | ||
| .globl _Z3fooP1A | ||
| .type _Z3fooP1A,@function | ||
| _Z3fooP1A: | ||
| paciasppc | ||
| ldr x8, [x0] | ||
| ldr w0, [x8] | ||
| retaasppcr x28 | ||
| .size _Z3fooP1A, .-_Z3fooP1A | ||
|
|
||
| .text | ||
| .globl _Z3bazP1A | ||
| .type _Z3bazP1A,@function | ||
| _Z3bazP1A: | ||
| 0: | ||
| paciasppc | ||
| ldr x7, [x0] | ||
| ldr w0, [x7] | ||
| retaasppc 0b | ||
| .size _Z3bazP1A, .-_Z3bazP1A | ||
|
|
||
| .globl _Z3barP1A | ||
| .type _Z3barP1A,@function | ||
| _Z3barP1A: | ||
| stp x29, x30, [sp, #-16]! | ||
| mov x29, sp | ||
| bl _Z3fooP1A | ||
| bl _Z3bazP1A | ||
| mul w0, w0, w0 | ||
| ldp x29, x30, [sp], #16 | ||
| ret | ||
| .size _Z3barP1A, .-_Z3barP1A | ||
|
|
||
| .globl main | ||
| .p2align 2 | ||
| .type main,@function | ||
| main: | ||
| mov w0, wzr | ||
| ret | ||
| .size main, .-main |
Oops, something went wrong.
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.