[clang] [ubsan] Improve lowering of @llvm.allow.ubsan.check (PR #119013)
Vitaly Buka via cfe-commits
cfe-commits at lists.llvm.org
Sat Dec 7 14:53:41 PST 2024
https://github.com/vitalybuka updated https://github.com/llvm/llvm-project/pull/119013
>From d66671a29061f80df52e4d4b7a2b6ce1de5cae27 Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Fri, 6 Dec 2024 11:18:20 -0800
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20change?=
=?UTF-8?q?s=20to=20main=20this=20commit=20is=20based=20on?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Created using spr 1.3.4
[skip ci]
---
clang/test/CodeGen/allow-ubsan-check-inline.c | 23 +++++++++++++++++++
1 file changed, 23 insertions(+)
create mode 100644 clang/test/CodeGen/allow-ubsan-check-inline.c
diff --git a/clang/test/CodeGen/allow-ubsan-check-inline.c b/clang/test/CodeGen/allow-ubsan-check-inline.c
new file mode 100644
index 00000000000000..cabe76d8034d77
--- /dev/null
+++ b/clang/test/CodeGen/allow-ubsan-check-inline.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s -fsanitize=signed-integer-overflow -mllvm -ubsan-guard-checks -O3 -mllvm -lower-allow-check-random-rate=1 -Rpass=lower-allow-check -Rpass-missed=lower-allow-check -fno-inline 2>&1 | FileCheck %s --check-prefixes=NOINL --implicit-check-not="remark:"
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s -fsanitize=signed-integer-overflow -mllvm -ubsan-guard-checks -O3 -mllvm -lower-allow-check-random-rate=1 -Rpass=lower-allow-check -Rpass-missed=lower-allow-check 2>&1 | FileCheck %s --check-prefixes=INLINE --implicit-check-not="remark:"
+
+int get();
+void set(int x);
+
+// We will only make decision in the `overflow` function.
+// NOINL-COUNT-1: remark: Allowed check:
+
+// FIXME: We will make decision on every inline.
+// INLINE-COUNT-1: remark: Allowed check:
+
+static void overflow() {
+ set(get() + get());
+}
+
+void test() {
+ overflow();
+ overflow();
+ overflow();
+ overflow();
+ overflow();
+}
More information about the cfe-commits
mailing list