Revert "[asan] Enable StackSafetyAnalysis by default"

This reverts commit 51fbab1345.
This causes the compiler to crash. Will file a issue to track the status.
This commit is contained in:
Zequan Wu 2024-01-11 14:15:52 -05:00
parent 3e82663b05
commit e7f7948751
10 changed files with 19 additions and 26 deletions

View File

@ -33,8 +33,6 @@ __attribute__((noinline)) void foo(int len) {
if (i) assert(!__asan_region_is_poisoned(bot, 96));
// VLA is unpoisoned at the end of iteration.
volatile char array[i];
// Ensure that asan-use-stack-safety does not optimize out the poisoning.
if (i) array[0] = 0;
assert(!(reinterpret_cast<uintptr_t>(array) & 31L));
// Alloca is unpoisoned at the end of iteration,
// because dominated by VLA.

View File

@ -1,9 +1,7 @@
// Test how we produce the scariness score.
// UAR Mode: runtime
// Case 26 loads a __asan_poison_memory_region-poisoned local variable, which is
// only instrumented when StackSafetyAnalysis is disabled.
// RUN: %clangxx_asan -O0 -mllvm -asan-use-stack-safety=0 %s -o %t
// RUN: %clangxx_asan -O0 %s -o %t
// On OSX and Windows, alloc_dealloc_mismatch=1 isn't 100% reliable, so it's
// off by default. It's safe for these tests, though, so we turn it on.
// RUN: export %env_asan_opts=symbolize=0:detect_stack_use_after_return=1:handle_abort=1:print_scariness=1:alloc_dealloc_mismatch=1
@ -38,7 +36,7 @@
// RUN: not %run %t 27 2>&1 | FileCheck %s --check-prefix=CHECK27
//
// UAR Mode: always
// RUN: %clangxx_asan -O0 %s -o %t -fsanitize-address-use-after-return=always -mllvm -asan-use-stack-safety=0
// RUN: %clangxx_asan -O0 %s -o %t -fsanitize-address-use-after-return=always
// On OSX and Windows, alloc_dealloc_mismatch=1 isn't 100% reliable, so it's
// off by default. It's safe for these tests, though, so we turn it on.
// RUN: export %env_asan_opts=symbolize=0:handle_abort=1:print_scariness=1:alloc_dealloc_mismatch=1

View File

@ -216,7 +216,7 @@ static cl::opt<bool> ClInstrumentWrites(
cl::Hidden, cl::init(true));
static cl::opt<bool>
ClUseStackSafety("asan-use-stack-safety", cl::Hidden, cl::init(true),
ClUseStackSafety("asan-use-stack-safety", cl::Hidden, cl::init(false),
cl::Hidden, cl::desc("Use Stack Safety analysis results"),
cl::Optional);

View File

@ -1,7 +1,7 @@
; REQUIRES: x86-registered-target
; RUN: opt < %s -S -asan-instrumentation-with-call-threshold=0 -passes=asan -asan-use-stack-safety=0 -o - | FileCheck %s --implicit-check-not="call {{.*}} @__asan_{{load|store|stack}}" --check-prefixes=CHECK,NOSAFETY
; RUN: opt < %s -S -asan-instrumentation-with-call-threshold=0 -passes=asan | FileCheck %s --implicit-check-not="call {{.*}} @__asan_{{load|store|stack}}"
; RUN: opt < %s -S -asan-instrumentation-with-call-threshold=0 -passes=asan -asan-use-stack-safety=1 -o - | FileCheck %s --implicit-check-not="call {{.*}} @__asan_{{load|store|stack}}"
; CHECK-LABEL: define i32 @load
define i32 @load() sanitize_address {

View File

@ -1,4 +1,4 @@
; RUN: opt < %s -passes=asan -asan-use-after-return=never -asan-use-stack-safety=0 -S | FileCheck %s
; RUN: opt < %s -passes=asan -asan-use-after-return=never -S | FileCheck %s
; Checks that llvm.dbg.declare instructions are updated
; accordingly as we merge allocas.

View File

@ -11,29 +11,26 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3
declare void @llvm.lifetime.start.p0(i64, ptr nocapture) nounwind
declare void @llvm.lifetime.end.p0(i64, ptr nocapture) nounwind
define i32 @basic_test(i64 %i) sanitize_address {
; CHECK-LABEL: define i32 @basic_test(
define i32 @basic_test() sanitize_address {
; CHECK-LABEL: define i32 @basic_test()
entry:
%retval = alloca i32, align 4
%c = alloca [2 x i8], align 1
%c = alloca i8, align 1
; Memory is poisoned in prologue: F1F1F1F104F3F8F2
; CHECK-UAS: store i64 -866676825215864335, ptr %{{[0-9]+}}
; CHECK-UAS-SS-NOT: store i64
call void @llvm.lifetime.start.p0(i64 1, ptr %c)
; Memory is unpoisoned at llvm.lifetime.start: 01
; CHECK-UAS: store i8 2, ptr %{{[0-9]+}}
; CHECK-UAS: store i8 1, ptr %{{[0-9]+}}
%ci = getelementptr inbounds [2 x i8], ptr %c, i64 0, i64 %i
store volatile i32 0, ptr %retval
store volatile i8 0, ptr %ci, align 1
store volatile i8 0, ptr %c, align 1
call void @llvm.lifetime.end.p0(i64 1, ptr %c)
; Memory is poisoned at llvm.lifetime.end: F8
; CHECK-UAS: store i8 -8, ptr %{{[0-9]+}}
; CHECK-UAS-SS-NOT: store i8 -8,
; Unpoison memory at function exit in UAS mode.
; CHECK-UAS: store i64 0, ptr %{{[0-9]+}}

View File

@ -1,6 +1,6 @@
; Test handling of llvm.lifetime intrinsics.
; RUN: opt < %s -passes=asan -asan-use-after-scope -asan-use-after-return=never -asan-use-stack-safety=0 -S | FileCheck %s --check-prefixes=CHECK,CHECK-DEFAULT
; RUN: opt < %s -passes=asan -asan-use-after-scope -asan-use-after-return=never -asan-use-stack-safety=0 -asan-instrument-dynamic-allocas=0 -S | FileCheck %s --check-prefixes=CHECK,CHECK-NO-DYNAMIC
; RUN: opt < %s -passes=asan -asan-use-after-scope -asan-use-after-return=never -S | FileCheck %s --check-prefixes=CHECK,CHECK-DEFAULT
; RUN: opt < %s -passes=asan -asan-use-after-scope -asan-use-after-return=never -asan-instrument-dynamic-allocas=0 -S | FileCheck %s --check-prefixes=CHECK,CHECK-NO-DYNAMIC
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

View File

@ -1,4 +1,4 @@
; RUN: opt -S -passes=asan -asan-use-stack-safety=0 -asan-skip-promotable-allocas=0 %s -o - | FileCheck %s
; RUN: opt -S -passes=asan -asan-skip-promotable-allocas=0 %s -o - | FileCheck %s
; Generated from:
; int bar(int y) {
; return y + 2;

View File

@ -1,14 +1,14 @@
; RUN: opt < %s -passes=asan -asan-stack-dynamic-alloca -asan-use-stack-safety=0 \
; RUN: opt < %s -passes=asan -asan-stack-dynamic-alloca \
; RUN: -asan-use-after-return=runtime -S | FileCheck %s \
; RUN: --check-prefixes=CHECK,CHECK-RUNTIME
; RUN: opt < %s -passes=asan -asan-stack-dynamic-alloca -asan-mapping-scale=5 -asan-use-stack-safety=0 \
; RUN: opt < %s -passes=asan -asan-stack-dynamic-alloca -asan-mapping-scale=5 \
; RUN: -asan-use-after-return=runtime -S | FileCheck %s \
; RUN: --check-prefixes=CHECK,CHECK-RUNTIME
; RUN: opt < %s -passes=asan -asan-stack-dynamic-alloca -asan-use-stack-safety=0 \
; RUN: opt < %s -passes=asan -asan-stack-dynamic-alloca \
; RUN: -asan-use-after-return=always -S | FileCheck %s \
; RUN: --check-prefixes=CHECK,CHECK-ALWAYS \
; RUN: --implicit-check-not=__asan_option_detect_stack_use_after_return
; RUN: opt < %s -passes=asan -asan-stack-dynamic-alloca -asan-use-stack-safety=0 \
; RUN: opt < %s -passes=asan -asan-stack-dynamic-alloca \
; RUN: -asan-use-after-return=always -S | FileCheck %s \
; RUN: --check-prefixes=CHECK,CHECK-ALWAYS \
; RUN: --implicit-check-not=__asan_option_detect_stack_use_after_return

View File

@ -1,8 +1,8 @@
; Test the ASan's stack layout.
; More tests in tests/Transforms/Utils/ASanStackFrameLayoutTest.cpp
; RUN: opt < %s -passes=asan -asan-use-stack-safety=0 -asan-stack-dynamic-alloca=0 -asan-use-after-scope -S \
; RUN: opt < %s -passes=asan -asan-stack-dynamic-alloca=0 -asan-use-after-scope -S \
; RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-STATIC
; RUN: opt < %s -passes=asan -asan-use-stack-safety=0 -asan-stack-dynamic-alloca=1 -asan-use-after-scope -S \
; RUN: opt < %s -passes=asan -asan-stack-dynamic-alloca=1 -asan-use-after-scope -S \
; RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-DYNAMIC
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"