-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[msan] Add experimental '-msan-or-shadow-for-strict-instructions' flag to pessimize output #128036
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
3 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
54 changes: 54 additions & 0 deletions
54
llvm/test/Instrumentation/MemorySanitizer/AArch64/or-shadow-for-strict-instructions.ll
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,54 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4 | ||
| ; RUN: opt < %s -passes=msan -S | FileCheck %s --check-prefixes=CLEAN | ||
vitalybuka marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ; RUN: opt < %s -passes=msan -S -msan-or-shadow-for-strict-instructions | FileCheck %s --check-prefixes=OR-SHADOW | ||
vitalybuka marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ; | ||
| ; This tests the behavior of the experimental "-msan-or-shadow-for-strict-instructions" | ||
| ; flag, which pessimizes the output by calculating the shadow of the return | ||
| ; value, even though it should be zero after passing the shadow check. | ||
| ; | ||
| ; This currently uses 'vcvtfxu2fp' as the "unknown" instruction; this test case | ||
| ; will need to be manually updated if that instruction becomes handled | ||
| ; properly (not by 'visitInstruction'). | ||
|
|
||
| target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" | ||
| target triple = "aarch64--linux-android9001" | ||
|
|
||
| define <2 x float> @ucvtf_2sc(<2 x i32> %A) nounwind #0 { | ||
| ; CLEAN-LABEL: define <2 x float> @ucvtf_2sc( | ||
| ; CLEAN-SAME: <2 x i32> [[A:%.*]]) #[[ATTR0:[0-9]+]] { | ||
| ; CLEAN-NEXT: [[TMP1:%.*]] = load <2 x i32>, ptr @__msan_param_tls, align 8 | ||
| ; CLEAN-NEXT: call void @llvm.donothing() | ||
| ; CLEAN-NEXT: [[TMP2:%.*]] = bitcast <2 x i32> [[TMP1]] to i64 | ||
| ; CLEAN-NEXT: [[_MSCMP:%.*]] = icmp ne i64 [[TMP2]], 0 | ||
| ; CLEAN-NEXT: br i1 [[_MSCMP]], label [[TMP3:%.*]], label [[TMP4:%.*]], !prof [[PROF1:![0-9]+]] | ||
| ; CLEAN: 3: | ||
| ; CLEAN-NEXT: call void @__msan_warning_noreturn() #[[ATTR3:[0-9]+]] | ||
| ; CLEAN-NEXT: unreachable | ||
| ; CLEAN: 4: | ||
| ; CLEAN-NEXT: [[TMPVAR3:%.*]] = call <2 x float> @llvm.aarch64.neon.vcvtfxu2fp.v2f32.v2i32(<2 x i32> [[A]], i32 1) | ||
| ; CLEAN-NEXT: store <2 x i32> zeroinitializer, ptr @__msan_retval_tls, align 8 | ||
| ; CLEAN-NEXT: ret <2 x float> [[TMPVAR3]] | ||
| ; | ||
| ; OR-SHADOW-LABEL: define <2 x float> @ucvtf_2sc( | ||
| ; OR-SHADOW-SAME: <2 x i32> [[A:%.*]]) #[[ATTR0:[0-9]+]] { | ||
| ; OR-SHADOW-NEXT: [[TMP1:%.*]] = load <2 x i32>, ptr @__msan_param_tls, align 8 | ||
| ; OR-SHADOW-NEXT: call void @llvm.donothing() | ||
| ; OR-SHADOW-NEXT: [[_MSPROP:%.*]] = or <2 x i32> [[TMP1]], zeroinitializer | ||
| ; OR-SHADOW-NEXT: [[_MSPROP1:%.*]] = or <2 x i32> [[_MSPROP]], zeroinitializer | ||
| ; OR-SHADOW-NEXT: [[TMP2:%.*]] = bitcast <2 x i32> [[TMP1]] to i64 | ||
| ; OR-SHADOW-NEXT: [[_MSCMP:%.*]] = icmp ne i64 [[TMP2]], 0 | ||
| ; OR-SHADOW-NEXT: br i1 [[_MSCMP]], label [[TMP3:%.*]], label [[TMP4:%.*]], !prof [[PROF1:![0-9]+]] | ||
| ; OR-SHADOW: 3: | ||
| ; OR-SHADOW-NEXT: call void @__msan_warning_noreturn() #[[ATTR3:[0-9]+]] | ||
| ; OR-SHADOW-NEXT: unreachable | ||
| ; OR-SHADOW: 4: | ||
| ; OR-SHADOW-NEXT: [[TMPVAR3:%.*]] = call <2 x float> @llvm.aarch64.neon.vcvtfxu2fp.v2f32.v2i32(<2 x i32> [[A]], i32 1) | ||
| ; OR-SHADOW-NEXT: store <2 x i32> [[_MSPROP1]], ptr @__msan_retval_tls, align 8 | ||
| ; OR-SHADOW-NEXT: ret <2 x float> [[TMPVAR3]] | ||
| %tmpvar3 = call <2 x float> @llvm.aarch64.neon.vcvtfxu2fp.v2f32.v2i32(<2 x i32> %A, i32 1) | ||
| ret <2 x float> %tmpvar3 | ||
| } | ||
|
|
||
| declare <2 x float> @llvm.aarch64.neon.vcvtfxu2fp.v2f32.v2i32(<2 x i32>, i32) nounwind readnone | ||
|
|
||
| attributes #0 = { sanitize_memory } | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure how this can be used?
If recover report and continue, why do we want to continue to report the same bad shadow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suppose:
The current behavior of visitInstruction in recover mode will print a UUM report at step 2, but the shadow is cleaned, and any subsequent UUM is unreported (even though there may be a meaningful UUM depending on which bytes of foo - top half or other bytes - were uninitialized).
So far, though, the interesting use case is actually the non-recover mode (even though it is conceptually a no-op).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amount of reports will be huge, and they are irrelevant till step 2 is fixed.