[clang] [NFC][ubsan] Pre-commit test with missed optimization (PR #119012)

Vitaly Buka via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 6 11:18:25 PST 2024


https://github.com/vitalybuka created https://github.com/llvm/llvm-project/pull/119012

None

>From 6eeac907ceebf425417204a4892d86b26ef6c1b7 Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Fri, 6 Dec 2024 11:18:07 -0800
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 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