]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/120924 - up --param uninit-max-chain-len
authorRichard Biener <rguenther@suse.de>
Fri, 18 Jul 2025 07:02:09 +0000 (09:02 +0200)
committerRichard Biener <rguenther@suse.de>
Fri, 18 Jul 2025 08:31:21 +0000 (10:31 +0200)
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.

gcc/params.opt
gcc/testsuite/gcc.dg/uninit-pr120924.c [new file with mode: 0644]

index 31aa0bd575332c48289c0b84c807021a3850b13a..c7d5fd4d13bd8f18079f1e50167c0c036e14ee26 100644 (file)
@@ -1177,7 +1177,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 (file)
index 0000000..bfc8ae9
--- /dev/null
@@ -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;
+  }
+}