[llvm-branch-commits] [clang] [NFC][clang][msan] Precommit test for -fsanitize-merge=memory (PR #238868)
Vitaly Buka via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Nov 4 08:56:46 PST 2026
https://github.com/vitalybuka created https://github.com/llvm/llvm-project/pull/238868
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
>From 0c99d12358d64c87a3bafa52523080ff17f8fe9d Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Wed, 4 Nov 2026 08:56:32 -0800
Subject: [PATCH] [spr] update
Created using spr 2.0.0-beta.2
---
clang/test/CodeGen/sanitize-memory-merge.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
create mode 100644 clang/test/CodeGen/sanitize-memory-merge.c
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;
+}
More information about the llvm-branch-commits
mailing list