-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[LLVM] Make sanitizers respect the disable_santizer_instrumentation attribute. #91732
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
DanielKristofKiss
merged 1 commit into
llvm:main
from
DanielKristofKiss:disable_sanitizer_inst
May 15, 2024
Merged
Changes from all commits
Commits
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
47 changes: 47 additions & 0 deletions
47
llvm/test/Instrumentation/DataFlowSanitizer/dataflow-disable-sanitizer-instrumentation.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,47 @@ | ||
|
||
; This test checks that we are not instrumenting sanitizer code. | ||
; RUN: opt < %s -passes='module(msan)' -S | FileCheck %s | ||
|
||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" | ||
target triple = "x86_64-unknown-linux-gnu" | ||
|
||
; Function with sanitize_memory is instrumented. | ||
; Function Attrs: nounwind uwtable | ||
define void @instr_sa(ptr %a) sanitize_memory { | ||
entry: | ||
%tmp1 = load i32, ptr %a, align 4 | ||
%tmp2 = add i32 %tmp1, 1 | ||
store i32 %tmp2, ptr %a, align 4 | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: @instr_sa | ||
; CHECK: %0 = load i64, ptr @__msan_param_tls | ||
|
||
|
||
; Function with disable_sanitizer_instrumentation is not instrumented. | ||
; Function Attrs: nounwind uwtable | ||
define void @noinstr_dsi(ptr %a) disable_sanitizer_instrumentation { | ||
entry: | ||
%tmp1 = load i32, ptr %a, align 4 | ||
%tmp2 = add i32 %tmp1, 1 | ||
store i32 %tmp2, ptr %a, align 4 | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: @noinstr_dsi | ||
; CHECK-NOT: %0 = load i64, ptr @__msan_param_tls | ||
|
||
|
||
; disable_sanitizer_instrumentation takes precedence over sanitize_memory. | ||
; Function Attrs: nounwind uwtable | ||
define void @noinstr_dsi_sa(ptr %a) disable_sanitizer_instrumentation sanitize_memory { | ||
entry: | ||
%tmp1 = load i32, ptr %a, align 4 | ||
%tmp2 = add i32 %tmp1, 1 | ||
store i32 %tmp2, ptr %a, align 4 | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: @noinstr_dsi_sa | ||
; CHECK-NOT: %0 = load i64, ptr @__msan_param_tls |
46 changes: 46 additions & 0 deletions
46
llvm/test/Instrumentation/SanitizerCoverage/coverage-disable-sanitizer-instrumentation.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,46 @@ | ||
; This test checks that we are not instrumenting sanitizer code. | ||
; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-control-flow -S | FileCheck %s | ||
|
||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" | ||
target triple = "x86_64-unknown-linux-gnu" | ||
|
||
; Function with sanitize_address is instrumented. | ||
; Function Attrs: nounwind uwtable | ||
define void @instr_sa(ptr %a) sanitize_address { | ||
entry: | ||
%tmp1 = load i32, ptr %a, align 4 | ||
%tmp2 = add i32 %tmp1, 1 | ||
store i32 %tmp2, ptr %a, align 4 | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: @instr_sa | ||
; CHECK: call void @__sanitizer_cov_trace_pc_guard( | ||
|
||
|
||
; Function with disable_sanitizer_instrumentation is not instrumented. | ||
; Function Attrs: nounwind uwtable | ||
define void @noinstr_dsi(ptr %a) disable_sanitizer_instrumentation { | ||
entry: | ||
%tmp1 = load i32, ptr %a, align 4 | ||
%tmp2 = add i32 %tmp1, 1 | ||
store i32 %tmp2, ptr %a, align 4 | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: @noinstr_dsi | ||
; CHECK-NOT: call void @__sanitizer_cov_trace_pc_guard( | ||
|
||
|
||
; disable_sanitizer_instrumentation takes precedence over sanitize_address. | ||
; Function Attrs: nounwind uwtable | ||
define void @noinstr_dsi_sa(ptr %a) disable_sanitizer_instrumentation sanitize_address { | ||
entry: | ||
%tmp1 = load i32, ptr %a, align 4 | ||
%tmp2 = add i32 %tmp1, 1 | ||
store i32 %tmp2, ptr %a, align 4 | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: @noinstr_dsi_sa | ||
; CHECK-NOT: call void @__sanitizer_cov_trace_pc_guard( |
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.