
Allow `-f[no]-sanitize-address-use-after-scope` to take effect under kernel-address sanitizer (`-fsanitize=kernel-address`). `use-after-scope` is now enabled by default under kernel-address sanitizer. Previously, users may have enabled `use-after-scope` checks for kernel-address sanitizer via `-mllvm -asan-use-after-scope=true`. While this may have worked for optimization levels > O0, the required lifetime intrinsics to allow for `use-after-scope` detection were not emitted under O0. This commit ensures the required lifetime intrinsics are emitted under O0 with kernel-address sanitizer.
32 lines
1.3 KiB
C
32 lines
1.3 KiB
C
// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - -O0 \
|
|
// RUN: -Xclang -disable-llvm-passes %s | FileCheck %s -check-prefix=CHECK-O0
|
|
// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - -O0 \
|
|
// RUN: -fsanitize=address -fsanitize-address-use-after-scope \
|
|
// RUN: -Xclang -disable-llvm-passes %s | FileCheck %s -check-prefix=LIFETIME
|
|
// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - -O0 \
|
|
// RUN: -fsanitize=kernel-address -fsanitize-address-use-after-scope \
|
|
// RUN: -Xclang -disable-llvm-passes %s | FileCheck %s -check-prefix=LIFETIME
|
|
// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - -O0 \
|
|
// RUN: -fsanitize=memory -Xclang -disable-llvm-passes %s | \
|
|
// RUN: FileCheck %s -check-prefix=LIFETIME
|
|
// RUN: %clang -target aarch64-linux-gnu -S -emit-llvm -o - -O0 \
|
|
// RUN: -fsanitize=hwaddress -Xclang -disable-llvm-passes %s | \
|
|
// RUN: FileCheck %s -check-prefix=LIFETIME
|
|
|
|
extern int bar(char *A, int n);
|
|
|
|
// CHECK-O0-NOT: @llvm.lifetime.start
|
|
int foo(int n) {
|
|
if (n) {
|
|
// LIFETIME: @llvm.lifetime.start.p0(i64 10, ptr {{.*}})
|
|
char A[10];
|
|
return bar(A, 1);
|
|
// LIFETIME: @llvm.lifetime.end.p0(i64 10, ptr {{.*}})
|
|
} else {
|
|
// LIFETIME: @llvm.lifetime.start.p0(i64 20, ptr {{.*}})
|
|
char A[20];
|
|
return bar(A, 2);
|
|
// LIFETIME: @llvm.lifetime.end.p0(i64 20, ptr {{.*}})
|
|
}
|
|
}
|