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

via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 6 11:19:00 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Vitaly Buka (vitalybuka)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/119012.diff


1 Files Affected:

- (added) clang/test/CodeGen/allow-ubsan-check-inline.c (+23) 


``````````diff
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();
+}

``````````

</details>


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


More information about the cfe-commits mailing list