https://github.com/eleviant created 
https://github.com/llvm/llvm-project/pull/196307

This reverts commit a4ddeba8daff36c8e6285fa3603185b4c9b41718, which raised 
concerns, see:
https://github.com/llvm/llvm-project/pull/193800

>From 991c532c58e84f7a0c804ace84550df7735d607e Mon Sep 17 00:00:00 2001
From: Evgeny Leviant <[email protected]>
Date: Thu, 7 May 2026 14:47:42 +0200
Subject: [PATCH] Revert "[clang] Don't omit null pointer checks with
 -fms-kernel (#193800)"

This reverts commit a4ddeba8daff36c8e6285fa3603185b4c9b41718, which
raised concerns, see:

https://github.com/llvm/llvm-project/pull/193800
---
 clang/docs/ReleaseNotes.rst              |  2 --
 clang/include/clang/Options/Options.td   |  4 ++--
 clang/test/CodeGen/MSKernel/null-deref.c | 16 ----------------
 3 files changed, 2 insertions(+), 20 deletions(-)
 delete mode 100644 clang/test/CodeGen/MSKernel/null-deref.c

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index cb19b80b7e994..ba235afffe20f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -291,8 +291,6 @@ Modified Compiler Flags
 - The `-mno-outline` and `-moutline` compiler flags are now allowed on RISC-V 
and X86, which both support the machine outliner.
 - The `-mno-outline` flag will now add the `nooutline` IR attribute, so that
   `-mno-outline` and `-moutline` objects can be mixed correctly during LTO.
-- The `-fms-kernel` flag will now implicitly add 
-fno-delete-null-pointer-checks.
-  Still -fdelete-null-pointer-checks can be used to override this behavior.
 
 Removed Compiler Flags
 ----------------------
diff --git a/clang/include/clang/Options/Options.td 
b/clang/include/clang/Options/Options.td
index 863e6b3d0871f..e21ea8a6529a1 100644
--- a/clang/include/clang/Options/Options.td
+++ b/clang/include/clang/Options/Options.td
@@ -3037,10 +3037,10 @@ defm rewrite_includes : BoolFOption<"rewrite-includes",
 defm directives_only : OptInCC1FFlag<"directives-only", "">;
 
 defm delete_null_pointer_checks : BoolFOption<"delete-null-pointer-checks",
-  CodeGenOpts<"NullPointerIsValid">, Default<"LangOpts->Kernel">,
+  CodeGenOpts<"NullPointerIsValid">, DefaultFalse,
   NegFlag<SetTrue, [], [ClangOption, CC1Option],
           "Do not treat usage of null pointers as undefined behavior">,
-  PosFlag<SetFalse, [], [ClangOption, CC1Option], "Treat usage of null 
pointers as undefined behavior (default)">,
+  PosFlag<SetFalse, [], [ClangOption], "Treat usage of null pointers as 
undefined behavior (default)">,
   BothFlags<[], [ClangOption, CLOption]>>,
   DocBrief<[{When enabled, treat null pointer dereference, creation of a 
reference to null,
 or passing a null pointer to a function parameter annotated with the "nonnull"
diff --git a/clang/test/CodeGen/MSKernel/null-deref.c 
b/clang/test/CodeGen/MSKernel/null-deref.c
deleted file mode 100644
index f23409115f50d..0000000000000
--- a/clang/test/CodeGen/MSKernel/null-deref.c
+++ /dev/null
@@ -1,16 +0,0 @@
-// Check that null pointer checks are not omited in kernel mode compilations
-// RUN: %clang_cc1 -fms-kernel -fms-extensions -triple x86_64-pc-windows-msvc 
%s -emit-llvm -o - | FileCheck %s
-// RUN: %clang_cc1 -fms-kernel -fms-extensions -triple x86_64-pc-windows-msvc 
-fdelete-null-pointer-checks %s -emit-llvm -o - | FileCheck %s 
--check-prefix=NOCHECK
-
-// CHECK: define dso_local i32 @process(ptr noundef %p) #0
-// CHECK: attributes #0 = {{.*}} null_pointer_is_valid
-// NOCHECK-NOT: null_pointer_is_valid
-
-struct Obj { int value; int extra; };
-
-int process(struct Obj* p) {
-    int v = p->value;
-    if (!p)
-        return -1;
-    return v + p->extra;
-}

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to