https://github.com/qinkunbao updated https://github.com/llvm/llvm-project/pull/142456
>From c0d1cb94966a24e12525bb5c1d863e43cd13e3c2 Mon Sep 17 00:00:00 2001 From: Qinkun Bao <qin...@google.com> Date: Mon, 2 Jun 2025 19:10:16 +0000 Subject: [PATCH 1/2] Change the test. Created using spr 1.3.6 --- ...relist.test => asan-global-ignorelist.test} | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) rename clang/test/CodeGen/{ubsan-global-ignorelist.test => asan-global-ignorelist.test} (60%) diff --git a/clang/test/CodeGen/ubsan-global-ignorelist.test b/clang/test/CodeGen/asan-global-ignorelist.test similarity index 60% rename from clang/test/CodeGen/ubsan-global-ignorelist.test rename to clang/test/CodeGen/asan-global-ignorelist.test index 8d7812217f331..3ec2847a8a4e9 100644 --- a/clang/test/CodeGen/ubsan-global-ignorelist.test +++ b/clang/test/CodeGen/asan-global-ignorelist.test @@ -1,11 +1,11 @@ // RUN: rm -rf %t // RUN: split-file %s %t -// RUN: %clang -target x86_64-unknown-linux-gnu -S -emit-llvm -fsanitize=bounds %t/test.c -o - | FileCheck %s --check-prefixes=CHECK,SANITIZE -// RUN: %clang -target x86_64-unknown-linux-gnu -S -emit-llvm -fsanitize=bounds -fsanitize-ignorelist=%t/order-0.ignorelist %t/test.c -o - | FileCheck %s --check-prefixes=CHECK,IGNORE -// RUN: %clang -target x86_64-unknown-linux-gnu -S -emit-llvm -fsanitize=bounds -fsanitize-ignorelist=%t/order-1.ignorelist %t/test.c -o - | FileCheck %s --check-prefixes=CHECK,SANITIZE -// RUN: %clang -target x86_64-unknown-linux-gnu -S -emit-llvm -fsanitize=bounds -fsanitize-ignorelist=%t/order-2.ignorelist %t/test.c -o - | FileCheck %s --check-prefixes=CHECK,IGNORE -// RUN: %clang -target x86_64-unknown-linux-gnu -S -emit-llvm -fsanitize=bounds -fsanitize-ignorelist=%t/order-3.ignorelist %t/test.c -o - | FileCheck %s --check-prefixes=CHECK,SANITIZE +// RUN: %clang -target x86_64-unknown-linux-gnu -S -emit-llvm -fsanitize=address %t/test.c -o - | FileCheck %s --check-prefixes=CHECK,SANITIZE +// RUN: %clang -target x86_64-unknown-linux-gnu -S -emit-llvm -fsanitize=address -fsanitize-ignorelist=%t/order-0.ignorelist %t/test.c -o - | FileCheck %s --check-prefixes=CHECK,IGNORE +// RUN: %clang -target x86_64-unknown-linux-gnu -S -emit-llvm -fsanitize=address -fsanitize-ignorelist=%t/order-1.ignorelist %t/test.c -o - | FileCheck %s --check-prefixes=CHECK,SANITIZE +// RUN: %clang -target x86_64-unknown-linux-gnu -S -emit-llvm -fsanitize=address -fsanitize-ignorelist=%t/order-2.ignorelist %t/test.c -o - | FileCheck %s --check-prefixes=CHECK,IGNORE +// RUN: %clang -target x86_64-unknown-linux-gnu -S -emit-llvm -fsanitize=address -fsanitize-ignorelist=%t/order-3.ignorelist %t/test.c -o - | FileCheck %s --check-prefixes=CHECK,SANITIZE // The same type can appear multiple times within an ignorelist. Any ``=sanitize`` type // entries enable sanitizer instrumentation, even if it was ignored by entries before. @@ -13,18 +13,22 @@ // precedence. //--- order-0.ignorelist +[address] global:global_array //--- order-1.ignorelist +[address] global:global_array global:global_array=sanitize //--- order-2.ignorelist +[address] global:* global:global_array=sanitize global:global_array //--- order-3.ignorelist +[address] global:* global:global_array=sanitize global:global* @@ -34,6 +38,6 @@ global:*array=sanitize unsigned global_array[100] = {-1}; // CHECK-LABEL: define dso_local i32 @test -// IGNORE-NOT: call void @__ubsan_handle_out_of_bounds -// SANITIZE: call void @__ubsan_handle_out_of_bounds +// IGNORE-NOT: call void @__asan_report_load4 +// SANITIZE: call void @__asan_report_load4 int test(int i) { return global_array[i]; } >From 0ae18c201b4a78aef9ed3df0528026bf7e6f2a67 Mon Sep 17 00:00:00 2001 From: Qinkun Bao <qin...@google.com> Date: Mon, 2 Jun 2025 19:45:30 +0000 Subject: [PATCH 2/2] Add implementation Created using spr 1.3.6 --- clang/lib/Basic/NoSanitizeList.cpp | 2 +- .../test/CodeGen/asan-global-ignorelist.test | 22 +++++++------------ 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/clang/lib/Basic/NoSanitizeList.cpp b/clang/lib/Basic/NoSanitizeList.cpp index ba36f78175422..24d2276f50ddf 100644 --- a/clang/lib/Basic/NoSanitizeList.cpp +++ b/clang/lib/Basic/NoSanitizeList.cpp @@ -44,7 +44,7 @@ bool NoSanitizeList::containsPrefix(SanitizerMask Mask, StringRef Prefix, bool NoSanitizeList::containsGlobal(SanitizerMask Mask, StringRef GlobalName, StringRef Category) const { - return SSCL->inSection(Mask, "global", GlobalName, Category); + return containsPrefix(Mask, "global", GlobalName, Category); } bool NoSanitizeList::containsType(SanitizerMask Mask, StringRef MangledTypeName, diff --git a/clang/test/CodeGen/asan-global-ignorelist.test b/clang/test/CodeGen/asan-global-ignorelist.test index 3ec2847a8a4e9..2bb37c100c067 100644 --- a/clang/test/CodeGen/asan-global-ignorelist.test +++ b/clang/test/CodeGen/asan-global-ignorelist.test @@ -1,11 +1,12 @@ // RUN: rm -rf %t // RUN: split-file %s %t -// RUN: %clang -target x86_64-unknown-linux-gnu -S -emit-llvm -fsanitize=address %t/test.c -o - | FileCheck %s --check-prefixes=CHECK,SANITIZE -// RUN: %clang -target x86_64-unknown-linux-gnu -S -emit-llvm -fsanitize=address -fsanitize-ignorelist=%t/order-0.ignorelist %t/test.c -o - | FileCheck %s --check-prefixes=CHECK,IGNORE -// RUN: %clang -target x86_64-unknown-linux-gnu -S -emit-llvm -fsanitize=address -fsanitize-ignorelist=%t/order-1.ignorelist %t/test.c -o - | FileCheck %s --check-prefixes=CHECK,SANITIZE -// RUN: %clang -target x86_64-unknown-linux-gnu -S -emit-llvm -fsanitize=address -fsanitize-ignorelist=%t/order-2.ignorelist %t/test.c -o - | FileCheck %s --check-prefixes=CHECK,IGNORE -// RUN: %clang -target x86_64-unknown-linux-gnu -S -emit-llvm -fsanitize=address -fsanitize-ignorelist=%t/order-3.ignorelist %t/test.c -o - | FileCheck %s --check-prefixes=CHECK,SANITIZE +// RUN: %clang -target x86_64-unknown-linux-gnu -S -emit-llvm -fsanitize=address %t/test.c -o - | FileCheck %s --check-prefixes=SANITIZE + +// RUN: %clang -target x86_64-unknown-linux-gnu -S -emit-llvm -fsanitize=address -fsanitize-ignorelist=%t/order-0.ignorelist %t/test.c -o - | FileCheck %s --check-prefixes=IGNORE +// RUN: %clang -target x86_64-unknown-linux-gnu -S -emit-llvm -fsanitize=address -fsanitize-ignorelist=%t/order-1.ignorelist %t/test.c -o - | FileCheck %s --check-prefixes=SANITIZE +// RUN: %clang -target x86_64-unknown-linux-gnu -S -emit-llvm -fsanitize=address -fsanitize-ignorelist=%t/order-2.ignorelist %t/test.c -o - | FileCheck %s --check-prefixes=IGNORE +// RUN: %clang -target x86_64-unknown-linux-gnu -S -emit-llvm -fsanitize=address -fsanitize-ignorelist=%t/order-3.ignorelist %t/test.c -o - | FileCheck %s --check-prefixes=SANITIZE // The same type can appear multiple times within an ignorelist. Any ``=sanitize`` type // entries enable sanitizer instrumentation, even if it was ignored by entries before. @@ -13,31 +14,24 @@ // precedence. //--- order-0.ignorelist -[address] global:global_array //--- order-1.ignorelist -[address] global:global_array global:global_array=sanitize //--- order-2.ignorelist -[address] global:* global:global_array=sanitize global:global_array //--- order-3.ignorelist -[address] global:* global:global_array=sanitize global:global* global:*array=sanitize //--- test.c +// SANITIZE: @global_array ={{.*}} global {{.*}}, comdat, align {{.*}} +// IGNORE: @global_array ={{.*}} global {{.*}}, no_sanitize_address, align {{.*}} unsigned global_array[100] = {-1}; - -// CHECK-LABEL: define dso_local i32 @test -// IGNORE-NOT: call void @__asan_report_load4 -// SANITIZE: call void @__asan_report_load4 -int test(int i) { return global_array[i]; } _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits