[llvm-branch-commits] [clang] [NFC][clang][msan] Precommit test for -fsanitize-merge=memory (PR #238868)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Nov 4 08:57:26 PST 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Vitaly Buka (vitalybuka)
<details>
<summary>Changes</summary>
Add baseline IR test for `-fsanitize-merge=memory` in `clang` before
wiring `CodeGenOpts.SanitizeMergeHandlers` to `MemorySanitizerOptions`.
Related to https://github.com/rust-lang/rust/issues/165040 (reducing
MSan binary size to offset the size overhead of fixing that issue).
Assisted-by: Gemini
---
Full diff: https://github.com/llvm/llvm-project/pull/238868.diff
1 Files Affected:
- (added) clang/test/CodeGen/sanitize-memory-merge.c (+21)
``````````diff
diff --git a/clang/test/CodeGen/sanitize-memory-merge.c b/clang/test/CodeGen/sanitize-memory-merge.c
new file mode 100644
index 0000000000000..c3f33aaeea66b
--- /dev/null
+++ b/clang/test/CodeGen/sanitize-memory-merge.c
@@ -0,0 +1,21 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --filter "call void @__msan_warning" --version 6
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=memory -O2 -emit-llvm -o - %s | FileCheck %s --implicit-check-not="call void @__msan_warning" --check-prefix=NOMERGE
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=memory -fsanitize-merge=memory -O2 -emit-llvm -o - %s | FileCheck %s --implicit-check-not="call void @__msan_warning" --check-prefix=MERGE
+
+// NOMERGE-LABEL: define dso_local noundef range(i32 0, 3) i32 @two_checks(
+// NOMERGE-SAME: ptr nofree noundef readonly captures(none) [[P:%.*]], ptr nofree noundef readonly captures(none) [[Q:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
+// NOMERGE: call void @__msan_warning_noreturn() #[[ATTR2:[0-9]+]]
+// NOMERGE: call void @__msan_warning_noreturn() #[[ATTR2]]
+//
+// MERGE-LABEL: define dso_local noundef range(i32 0, 3) i32 @two_checks(
+// MERGE-SAME: ptr nofree noundef readonly captures(none) [[P:%.*]], ptr nofree noundef readonly captures(none) [[Q:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
+// MERGE: call void @__msan_warning_noreturn() #[[ATTR2:[0-9]+]]
+// MERGE: call void @__msan_warning_noreturn() #[[ATTR2]]
+//
+int two_checks(int *p, int *q) {
+ if (*p)
+ return 1;
+ if (*q)
+ return 2;
+ return 0;
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/238868
More information about the llvm-branch-commits
mailing list