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.

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

OK for trunk?  OK for 15 branch?

I'll note that increased compile-time will be only for the case
where we possibly emit an uninit diagnostic - correct diagnostics
might now take longer to be analyzed as such and false positives
might now no longer appear.

Thanks,
Richard.

        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                         |  2 +-
 gcc/testsuite/gcc.dg/uninit-pr120924.c | 34 ++++++++++++++++++++++++++
 2 files changed, 35 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.dg/uninit-pr120924.c

diff --git a/gcc/params.opt b/gcc/params.opt
index 31aa0bd5753..c7d5fd4d13b 100644
--- a/gcc/params.opt
+++ b/gcc/params.opt
@@ -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
index 00000000000..bfc8ae9fd50
--- /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;
+  }
+}
-- 
2.43.0

Reply via email to