Author: eleviant
Date: 2026-05-07T15:09:57+02:00
New Revision: 3ebc9abcfd5165b65f9dcb8ae48e73a0a4218bb0

URL: 
https://github.com/llvm/llvm-project/commit/3ebc9abcfd5165b65f9dcb8ae48e73a0a4218bb0
DIFF: 
https://github.com/llvm/llvm-project/commit/3ebc9abcfd5165b65f9dcb8ae48e73a0a4218bb0.diff

LOG: Revert "[clang] Don't omit null pointer checks with -fms-kernel (#196307)

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

Added: 
    

Modified: 
    clang/docs/ReleaseNotes.rst
    clang/include/clang/Options/Options.td

Removed: 
    clang/test/CodeGen/MSKernel/null-deref.c


################################################################################
diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 07c1580a1057e..c83a1bd0ab2e9 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 38cd7d4b86a0b..5eeabf4c33b76 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