This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/63224] False Positive for -Wmaybe-uninitialized at -Os, not -O2


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63224

--- Comment #7 from Sebastian Huber <sebastian.huber@embedded-brains.de> ---
I reduced the test case using the delta tool to:

void foo(void);

void bar(int s, int *a)
{
        int i;
        int c;

        for (i = 0; s != 0 && (c = a[i]); ++i) {
        }

        if (s == 2 && c == 0) {
        } else if (s != 0) {
                foo();
        }
}

cp test.c Os.c
cp test.c O2.c
arm-rtems4.11-gcc -Wfatal-errors -Wall -Os -S Os.c -o Os.s
-fdump-tree-all-all-lineno
Os.c: In function 'bar':
Os.c:11:25: warning: 'c' may be used uninitialized in this function
[-Wmaybe-uninitialized]
         if (s == 2 && c == 0) {
                         ^
arm-rtems4.11-gcc -Wfatal-errors -Wall -O2 -S O2.c -o O2.s
-fdump-tree-all-all-lineno

diff -u O*c*uni*
--- O2.c.140t.uninit1   2014-09-12 09:20:47.983177990 +0200
+++ Os.c.140t.uninit1   2014-09-12 09:20:47.909178064 +0200
@@ -5,73 +5,138 @@
 Pass statistics:
 ----------------

+[WORKLIST]: add to initial list: c_2 = PHI <c_5(D)(2), c_12(8)>
+[CHECK]: examining phi: c_2 = PHI <c_5(D)(2), c_12(8)>
+
+[CHECK] Found def edge 1 in c_2 = PHI <c_5(D)(2), c_12(8)>
+[CHECK]: Found unguarded use: c_3 = PHI <c_2(9), 0(10)>
+[WORKLIST]: Update worklist with phi: c_3 = PHI <c_2(9), 0(10)>
+[CHECK]: examining phi: c_3 = PHI <c_2(9), 0(10)>
+[CHECK]: Found unguarded use: _15 = c_3 == 0;

 Pass statistics:
 ----------------

 bar (intD.3 sD.4075, intD.3 * aD.4076)
 {
-  unsigned int ivtmp.12D.4111;
+  unsigned int ivtmp.10D.4109;
   intD.3 cD.4080;
   intD.3 iD.4079;
+  _BoolD.1375 _14;
+  _BoolD.1375 _15;
+  _BoolD.1375 _16;
+  _BoolD.1375 _21;
+  intD.3 * _23;
+  voidD.63 * _24;

 ;;   basic block 2, loop depth 0, count 0, freq 880, maybe hot
-;;    prev block 0, next block 6, flags: (NEW, REACHABLE)
+;;    prev block 0, next block 3, flags: (NEW, REACHABLE)
 ;;    pred:       ENTRY [100.0%]  (FALLTHRU,EXECUTABLE)
-;;   starting at line 8
-  [O2.c : 8:9] if (s_6(D) != 0)
-    goto <bb 3>;
+;;   starting at line -1
+  _23 = a_9(D) + 4294967292;
+  # RANGE [0, 4294967295]
+  ivtmp.10_22 = (unsigned int) _23;
+;;    succ:       3 [100.0%]  (FALLTHRU,EXECUTABLE)
+
+;;   basic block 3, loop depth 1, count 0, freq 10000, maybe hot
+;;    prev block 2, next block 4, flags: (NEW, REACHABLE)
+;;    pred:       2 [100.0%]  (FALLTHRU,EXECUTABLE)
+;;                8 [100.0%]  (FALLTHRU,DFS_BACK)
+;;   starting at line 8, discriminator 1
+  # RANGE ~[0, 0]
+  # c_2 = PHI <c_5(D)(2), c_12(8)>
+  # ivtmp.10_19 = PHI <ivtmp.10_22(2), ivtmp.10_18(8)>
+  [Os.c : 8:9] if (s_6(D) != 0)
+    goto <bb 4>;
   else
-    goto <bb 6>;
-;;    succ:       3 [95.5%]  (TRUE_VALUE,EXECUTABLE)
-;;                6 [4.5%]  (FALSE_VALUE,EXECUTABLE)
-
-;;   basic block 6, loop depth 0, count 0, freq 40, maybe hot
-;;    prev block 2, next block 3, flags: (NEW)
-;;    pred:       2 [4.5%]  (FALSE_VALUE,EXECUTABLE)
+    goto <bb 9>;
+;;    succ:       4 [95.5%]  (TRUE_VALUE,EXECUTABLE)
+;;                9 [4.5%]  (FALSE_VALUE,EXECUTABLE)
+
+;;   basic block 4, loop depth 1, count 0, freq 9550, maybe hot
+;;    prev block 3, next block 10, flags: (NEW, REACHABLE)
+;;    pred:       3 [95.5%]  (TRUE_VALUE,EXECUTABLE)
+;;   starting at line -1, discriminator 3
+  # RANGE [0, 4294967295]
+  ivtmp.10_18 = ivtmp.10_19 + 4;
+  # PT = nonlocal 
+  _24 = (voidD.63 *) ivtmp.10_18;
+  [Os.c : 8:34] # VUSE <.MEM_11(D)>
+  c_12 = MEM[base: _24, offset: 0B];
+  [Os.c : 8:28] if (c_12 != 0)
+    goto <bb 8>;
+  else
+    goto <bb 10>;
+;;    succ:       8 [95.5%]  (TRUE_VALUE,EXECUTABLE)
+;;                10 [4.5%]  (FALSE_VALUE,EXECUTABLE)
+
+;;   basic block 10, loop depth 0, count 0, freq 430, maybe hot
+;;    prev block 4, next block 8, flags: (NEW)
+;;    pred:       4 [4.5%]  (FALSE_VALUE,EXECUTABLE)
 ;; 
   goto <bb 5>;
 ;;    succ:       5 [100.0%]  (FALLTHRU)

-;;   basic block 3, loop depth 0, count 0, freq 430, maybe hot
-;;   Invalid sum of incoming frequencies 840, should be 430
-;;    prev block 6, next block 7, flags: (NEW, REACHABLE)
-;;    pred:       2 [95.5%]  (TRUE_VALUE,EXECUTABLE)
-;;   starting at line 11
-  [O2.c : 11:12] if (s_6(D) == 2)
-    goto <bb 7>;
-  else
-    goto <bb 4>;
-;;    succ:       7 [79.8%]  (TRUE_VALUE,EXECUTABLE)
-;;                4 [20.2%]  (FALSE_VALUE,EXECUTABLE)
+;;   basic block 8, loop depth 1, count 0, freq 9120, maybe hot
+;;    prev block 10, next block 9, flags: (NEW)
+;;    pred:       4 [95.5%]  (TRUE_VALUE,EXECUTABLE)
+;; 
+  goto <bb 3>;
+;;    succ:       3 [100.0%]  (FALLTHRU,DFS_BACK)

-;;   basic block 7, loop depth 0, count 0, freq 343, maybe hot
-;;    prev block 3, next block 4, flags: (NEW)
-;;    pred:       3 [79.8%]  (TRUE_VALUE,EXECUTABLE)
+;;   basic block 9, loop depth 0, count 0, freq 450, maybe hot
+;;    prev block 8, next block 5, flags: (NEW)
+;;    pred:       3 [4.5%]  (FALSE_VALUE,EXECUTABLE)
 ;; 
-  goto <bb 5>;
 ;;    succ:       5 [100.0%]  (FALLTHRU)

-;;   basic block 4, loop depth 0, count 0, freq 209, maybe hot
-;;   Invalid sum of incoming frequencies 87, should be 209
-;;    prev block 7, next block 5, flags: (NEW, REACHABLE)
-;;    pred:       3 [20.2%]  (FALSE_VALUE,EXECUTABLE)
+;;   basic block 5, loop depth 0, count 0, freq 880, maybe hot
+;;    prev block 9, next block 11, flags: (NEW, REACHABLE)
+;;    pred:       9 [100.0%]  (FALLTHRU)
+;;                10 [100.0%]  (FALLTHRU)
+;;   starting at line 11
+  # c_3 = PHI <c_2(9), 0(10)>
+  [Os.c : 11:15] # RANGE [0, 1]
+  _14 = s_6(D) == 2;
+  [Os.c : 11:25] # RANGE [0, 1]
+  _15 = c_3 == 0;
+  [Os.c : 11:20] # RANGE [0, 1]
+  _16 = _15 & _14;
+  [Os.c : 12:19] # RANGE [0, 1]
+  _21 = s_6(D) != 0;
+  [Os.c : 12:19] if (_16 < _21)
+    goto <bb 6>;
+  else
+    goto <bb 11>;
+;;    succ:       6 [39.0%]  (TRUE_VALUE,EXECUTABLE)
+;;                11 [61.0%]  (FALSE_VALUE,EXECUTABLE)
+
+;;   basic block 11, loop depth 0, count 0, freq 537, maybe hot
+;;    prev block 5, next block 6, flags: (NEW)
+;;    pred:       5 [61.0%]  (FALSE_VALUE,EXECUTABLE)
+;; 
+  goto <bb 7>;
+;;    succ:       7 [100.0%]  (FALLTHRU)
+
+;;   basic block 6, loop depth 0, count 0, freq 209, maybe hot
+;;   Invalid sum of incoming frequencies 343, should be 209
+;;    prev block 11, next block 7, flags: (NEW, REACHABLE)
+;;    pred:       5 [39.0%]  (TRUE_VALUE,EXECUTABLE)
 ;;   starting at line 13
-  [O2.c : 13:17] # .MEM_17 = VDEF <.MEM_11(D)>
+  [Os.c : 13:17] # .MEM_17 = VDEF <.MEM_11(D)>
   # USE = nonlocal 
   # CLB = nonlocal 
   fooD.4074 (); [tail call]
-;;    succ:       5 [100.0%]  (FALLTHRU,EXECUTABLE)
+;;    succ:       7 [100.0%]  (FALLTHRU,EXECUTABLE)

-;;   basic block 5, loop depth 0, count 0, freq 880, maybe hot
-;;   Invalid sum of incoming frequencies 592, should be 880
-;;    prev block 4, next block 1, flags: (NEW, REACHABLE)
-;;    pred:       4 [100.0%]  (FALLTHRU,EXECUTABLE)
-;;                7 [100.0%]  (FALLTHRU)
-;;                6 [100.0%]  (FALLTHRU)
+;;   basic block 7, loop depth 0, count 0, freq 880, maybe hot
+;;   Invalid sum of incoming frequencies 746, should be 880
+;;    prev block 6, next block 1, flags: (NEW, REACHABLE)
+;;    pred:       6 [100.0%]  (FALLTHRU,EXECUTABLE)
+;;                11 [100.0%]  (FALLTHRU)
 ;;   starting at line 15
-  # .MEM_4 = PHI <.MEM_17(4), .MEM_11(D)(7), .MEM_11(D)(6)>
-  [O2.c : 15:1] # VUSE <.MEM_4>
+  # .MEM_4 = PHI <.MEM_17(6), .MEM_11(D)(11)>
+  [Os.c : 15:1] # VUSE <.MEM_4>
   return;
 ;;    succ:       EXIT [100.0%]


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]