Skip to content

Conversation

@thurstond
Copy link
Contributor

This testcase shows that adding a ubsan check and then removing it during the LowerAllowCheck pass does not entirely undo the effects of adding the check.

This testcase shows that adding a ubsan check and then removing it
during the LowerAllowCheck pass does not entirely undo the effects of
adding the check.
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Oct 22, 2025
@llvmbot
Copy link
Member

llvmbot commented Oct 22, 2025

@llvm/pr-subscribers-clang

Author: Thurston Dang (thurstond)

Changes

This testcase shows that adding a ubsan check and then removing it during the LowerAllowCheck pass does not entirely undo the effects of adding the check.


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

1 Files Affected:

  • (added) clang/test/CodeGen/allow-ubsan-check-divergence.c (+30)
diff --git a/clang/test/CodeGen/allow-ubsan-check-divergence.c b/clang/test/CodeGen/allow-ubsan-check-divergence.c
new file mode 100644
index 0000000000000..a21d4f693269b
--- /dev/null
+++ b/clang/test/CodeGen/allow-ubsan-check-divergence.c
@@ -0,0 +1,30 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 6
+
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -O1 -o - %s \
+// RUN:     | FileCheck %s --check-prefixes=CLEAN-O1
+
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -O1 -o - %s \
+// RUN:     -fsanitize=signed-integer-overflow \
+// RUN:     -fsanitize-skip-hot-cutoff=signed-integer-overflow=1.0 \
+// RUN:     -fallow-runtime-check-skip-hot-cutoff=1.0 \
+// RUN:     | FileCheck %s --check-prefixes=UBSAN-O1
+
+// This test shows that -fsanitize-skip-hot-cutoff=...=1.0 plus
+// -fallow-runtime-check-skip-hot-cutoff=1.0 does not perfectly undo the
+// effects of -fsanitize.
+
+// CLEAN-O1-LABEL: define dso_local i32 @overflow(
+// CLEAN-O1-SAME: i32 noundef [[X:%.*]], i32 noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
+// CLEAN-O1-NEXT:  [[ENTRY:.*:]]
+// CLEAN-O1-NEXT:    [[ADD:%.*]] = add nsw i32 [[Y]], [[X]]
+// CLEAN-O1-NEXT:    ret i32 [[ADD]]
+//
+// UBSAN-O1-LABEL: define dso_local noundef i32 @overflow(
+// UBSAN-O1-SAME: i32 noundef [[X:%.*]], i32 noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
+// UBSAN-O1-NEXT:  [[ENTRY:.*:]]
+// UBSAN-O1-NEXT:    [[TMP0:%.*]] = add i32 [[X]], [[Y]]
+// UBSAN-O1-NEXT:    ret i32 [[TMP0]]
+//
+int overflow(int x, int y) {
+  return x + y;
+}

@thurstond thurstond merged commit f2c235a into llvm:main Oct 22, 2025
12 checks passed
mikolaj-pirog pushed a commit to mikolaj-pirog/llvm-project that referenced this pull request Oct 23, 2025
This testcase shows that adding a ubsan check and then removing it
during the LowerAllowCheck pass does not entirely undo the effects of
adding the check.
dvbuka pushed a commit to dvbuka/llvm-project that referenced this pull request Oct 27, 2025
This testcase shows that adding a ubsan check and then removing it
during the LowerAllowCheck pass does not entirely undo the effects of
adding the check.
Lukacma pushed a commit to Lukacma/llvm-project that referenced this pull request Oct 29, 2025
This testcase shows that adding a ubsan check and then removing it
during the LowerAllowCheck pass does not entirely undo the effects of
adding the check.
aokblast pushed a commit to aokblast/llvm-project that referenced this pull request Oct 30, 2025
This testcase shows that adding a ubsan check and then removing it
during the LowerAllowCheck pass does not entirely undo the effects of
adding the check.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants