-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[MTE] add stack frame history buffer #86356
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
fmayer
merged 13 commits into
users/fmayer/spr/main.wip-mte-stack-record
from
users/fmayer/spr/wip-mte-stack-record
May 28, 2024
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
08fdb4e
[𝘀𝗽𝗿] initial version
fmayer 86bef23
update
fmayer a64c5d6
update
fmayer 76eee17
rebase
fmayer 6a104e5
update
fmayer cf27e51
dwarf
fmayer 8591fb3
api lvl
fmayer 66fbd75
hidden
fmayer a9c5547
api lvl
fmayer 62c2812
fp
fmayer 79ec757
comment
fmayer 63dff44
ir test
fmayer 6e81792
codegen test
fmayer 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
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,69 @@ | ||
; RUN: opt < %s -aarch64-stack-tagging -stack-tagging-use-stack-safety=0 -S -o - | FileCheck %s --check-prefixes=CHECK | ||
; RUN: opt < %s -aarch64-stack-tagging -stack-tagging-use-stack-safety=0 -S -stack-tagging-record-stack-history=instr -o - | FileCheck %s --check-prefixes=INSTR | ||
; RUN llc -mattr=+mte -stack-tagging-use-stack-safety=0 -stack-tagging-record-stack-history=instr %s -o - | FileCheck %s --check-prefixes=ASMINSTR | ||
|
||
|
||
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" | ||
target triple = "aarch64--linux-android10000" | ||
|
||
declare void @use8(ptr) | ||
declare void @use32(ptr) | ||
declare void @llvm.lifetime.start.p0(i64, ptr nocapture) | ||
declare void @llvm.lifetime.end.p0(i64, ptr nocapture) | ||
|
||
define dso_local void @noUse32(ptr) sanitize_memtag { | ||
entry: | ||
ret void | ||
} | ||
|
||
define void @OneVar() sanitize_memtag { | ||
entry: | ||
%x = alloca i32, align 4 | ||
call void @use32(ptr %x) | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: define void @OneVar( | ||
; CHECK: [[BASE:%.*]] = call ptr @llvm.aarch64.irg.sp(i64 0) | ||
; CHECK: [[X:%.*]] = alloca { i32, [12 x i8] }, align 16 | ||
; CHECK: [[TX:%.*]] = call ptr @llvm.aarch64.tagp.{{.*}}(ptr [[X]], ptr [[BASE]], i64 0) | ||
; CHECK: ret void | ||
|
||
; INSTR-LABEL: define void @OneVar( | ||
; INSTR: [[BASE:%.*]] = call ptr @llvm.aarch64.irg.sp(i64 0) | ||
; INSTR: [[TLS:%.*]] = call ptr @llvm.thread.pointer() | ||
; INSTR: [[TLS_SLOT:%.*]] = getelementptr i8, ptr [[TLS]], i32 -24 | ||
; INSTR: [[TLS_VALUE:%.*]] = load i64, ptr %1, align 8 | ||
; INSTR: [[FP:%.*]] = call ptr @llvm.frameaddress.p0(i32 0) | ||
; INSTR: [[FP_INT:%.*]] = ptrtoint ptr %3 to i64 | ||
; INSTR: [[BASE_INT:%.*]] = ptrtoint ptr %basetag to i64 | ||
; INSTR: [[BASE_TAG:%.*]] = and i64 [[BASE_INT]], 1080863910568919040 | ||
; INSTR: [[TAGGED_FP:%.*]] = or i64 [[FP_INT]], [[BASE_TAG]] | ||
; INSTR: [[PC:%.*]] = call i64 @llvm.read_register.i64(metadata !0) | ||
; INSTR: [[TLS_VALUE_PTR:%.*]] = inttoptr i64 [[TLS_VALUE]] to ptr | ||
; INSTR: store i64 [[PC]], ptr [[TLS_VALUE_PTR]], align 8 | ||
; INSTR: [[SECOND_SLOT:%.*]] = getelementptr i64, ptr [[TLS_VALUE_PTR]], i64 1 | ||
; INSTR: store i64 [[TAGGED_FP]], ptr [[SECOND_SLOT]], align 8 | ||
; INSTR: [[SIZE_IN_PAGES:%.*]] = ashr i64 [[TLS_VALUE]], 56 | ||
; INSTR: [[WRAP_MASK_INTERMEDIARY:%.*]] = shl nuw nsw i64 [[SIZE_IN_PAGES]], 12 | ||
; INSTR: [[WRAP_MASK:%.*]] = xor i64 [[WRAP_MASK_INTERMEDIARY]], -1 | ||
; INSTR: [[NEXT_TLS_VALUE_BEFORE_WRAP:%.*]] = add i64 [[TLS_VALUE]], 16 | ||
; INSTR: [[NEXT_TLS_VALUE:%.*]] = and i64 [[NEXT_TLS_VALUE_BEFORE_WRAP]], [[WRAP_MASK]] | ||
; INSTR: store i64 [[NEXT_TLS_VALUE]], ptr [[TLS_SLOT]], align 8 | ||
; INSTR: [[X:%.*]] = alloca { i32, [12 x i8] }, align 16 | ||
; INSTR: [[TX:%.*]] = call ptr @llvm.aarch64.tagp.{{.*}}(ptr [[X]], ptr [[BASE]], i64 0) | ||
; INSTR: [[PC:!.*]] = !{!"pc"} | ||
|
||
; ASMINSTR-LABEL: OneVar: | ||
; ASMINSTR: mrs [[TLS:x.*]], TPIDR_EL0 | ||
; ASMINSTR: irg [[BASE:x.*]], sp | ||
; ASMINSTR: adr [[PC:x.*]], #0 | ||
; ASMINSTR: ldur [[TLS_SLOT:x.*]], [[[TLS]], #-24] | ||
; ASMINSTR: and [[SP_TAG:x.*]], [[BASE]], #0xf00000000000000 | ||
; ASMINSTR: orr [[TAGGED_FP]], x29, [[SP_TAG]] | ||
; ASMINSTR: asr [[TLS_SIZE:x.*]], [[TLS_SLOT]], #56 | ||
; ASMINSTR: add [[NEXT_TLS_VALUE_BEFORE_WRAP:x.*]], [[TLS_SLOT]], #16 | ||
; ASMINSTR: stp [[PC]], [[TAGGED_FP]], [[[TLS_SLOT]]] | ||
; ASMINSTR: bic [[NEXT_TLS_VALUE:x.*]], [[NEXT_TLS_VALUE_BEFORE_WRAP]], [[TLS_SIZE]], lsl #12 | ||
; ASMINSTR: stur [[NEXT_TLS_VALUE]], [[[TLS]], #-24] | ||
; ASMINSTR: stg [[BASE]], [[[BASE]]] |
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.