https://gcc.gnu.org/g:e1828db8e75a56eebf8ede53e1ae4fcbd0f3376f

commit r15-10004-ge1828db8e75a56eebf8ede53e1ae4fcbd0f3376f
Author: Richard Biener <rguent...@suse.de>
Date:   Fri Jul 18 09:02:09 2025 +0200

    tree-optimization/120924 - up --param uninit-max-chain-len
    
    The PR shows that the uninit analysis limits are set too low in
    cases we lower switches to ifs as happens on s390x for a linux
    kernel TU.  This causes false positive uninit diagnostics as we
    abort the attempt to prove that a value is initialized on all
    paths.  The new testcase only would require upping to 9.
    
            PR tree-optimization/120924
            * params.opt (uninit-max-chain-len): Up from 8 to 12.
    
            * gcc.dg/uninit-pr120924.c: New testcase.
    
    (cherry picked from commit cf9a479e3f909d5217e954788eb3c5b569e4bc52)

Diff:
---
 gcc/params.opt                         |  2 +-
 gcc/testsuite/gcc.dg/uninit-pr120924.c | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/gcc/params.opt b/gcc/params.opt
index 412b6701fadc..64e453d29b74 100644
--- a/gcc/params.opt
+++ b/gcc/params.opt
@@ -1181,7 +1181,7 @@ Common Joined UInteger 
Var(param_uninit_control_dep_attempts) Init(1000) Integer
 Maximum number of nested calls to search for control dependencies during 
uninitialized variable analysis.
 
 -param=uninit-max-chain-len=
-Common Joined UInteger Var(param_uninit_max_chain_len) Init(8) IntegerRange(1, 
128) Param Optimization
+Common Joined UInteger Var(param_uninit_max_chain_len) Init(12) 
IntegerRange(1, 128) Param Optimization
 Maximum number of predicates anded for each predicate ored in the normalized
 predicate chain.
 
diff --git a/gcc/testsuite/gcc.dg/uninit-pr120924.c 
b/gcc/testsuite/gcc.dg/uninit-pr120924.c
new file mode 100644
index 000000000000..bfc8ae9fd508
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/uninit-pr120924.c
@@ -0,0 +1,34 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wmaybe-uninitialized" } */
+
+int foo(int);
+enum {
+  BPF_TRACE_RAW_TP,
+  BPF_MODIFY_RETURN,
+  BPF_LSM_MAC,
+  BPF_TRACE_ITER,
+  BPF_LSM_CGROUP
+};
+int btf_get_kernel_prefix_kind_prefix, obj_1, attach_name___trans_tmp_1;
+char attach_name_fn_name;
+void attach_name(int attach_type)
+{
+  int mod_len;
+  char mod_name = attach_name_fn_name;
+  if (attach_name_fn_name)
+    mod_len = mod_name;
+  for (; obj_1;) {
+    if (mod_name && foo(mod_len))
+      continue;
+    switch (attach_type) {
+    case BPF_TRACE_RAW_TP:
+    case BPF_LSM_MAC:
+    case BPF_LSM_CGROUP:
+      btf_get_kernel_prefix_kind_prefix = 1;
+    case BPF_TRACE_ITER:
+      attach_name_fn_name = 2;
+    }
+    if (attach_name___trans_tmp_1)
+      return;
+  }
+}

Reply via email to