YaK:: Debugging bad ShowHex arg (yadd2all -Os) [Changes]   [Calendar]   [Search]   [Index]   [PhotoTags]   
[mega_changes]
[photos]

Debugging bad ShowHex arg (yadd2all -Os)

{Term|02}/DD:sleep 1 ; yadd2all
:A:E123
:i:0000
:&:0184
:g:002E
:i:0001
:&:0184
:g:006F


That &:0184 should be E123 or following.

This code follows a function call and random D was returned:


"yadd2all.0134ca6ab4"+00c5 N e0c5:1e02     {exg   d,y              }  a=00 b=00 x=1ee5:3a69 y=0184:c84a u=1ef3:e123 s=1ef3:e123,2e00 cc=EfhinZvc dp=00 #5035340720 {{}}

"yadd2all.0134ca6ab4"+00c7 N e0c7:e3c4     {addd  ,u               }  a=e1 b=23 x=1ee5:3a69 y=0184:c84a u=1ef3:e123 s=1ef3:e123,2e00 cc=EfhiNzvc dp=00 #5035340721 {{}}  1ef3:e123

"yadd2all.0134ca6ab4"+00c9 N e0c9:1e02     {exg   d,y              }  a=01 b=84 x=1ee5:3a69 y=e123:4845 u=1ef3:e123 s=1ef3:e123,2e00 cc=EfhiNzvc dp=00 #5035340722 {{}}

"yadd2all.0134ca6ab4"+00cb N e0cb:1f01     {tfr   d,x              }  a=01 b=84 x=0184:c84a y=e123:4845 u=1ef3:e123 s=1ef3:e123,2e00 cc=EfhiNzvc dp=00 #5035340723 {{}}

"yadd2all.0134ca6ab4"+00cd N e0cd:c626     {ldb   #$26             }  a=01 b=26 x=0184:c84a y=e123:4845 u=1ef3:e123 s=1ef3:e123,2e00 cc=Efhinzvc dp=00 #5035340724 {{}}  e0ce:26

"yadd2all.0134ca6ab4"+00cf N e0cf:17ff3b   {lbsr  $e00d            }  a=01 b=26 x=0184:c84a y=e123:4845 u=1ef3:e123 s=1ef1:e0d2,e123 cc=Efhinzvc dp=00 #5035340725 {{}}



That's calling ShowHex with a random value in X, that came from random D.

What were we thinking?

; (insn# # # (set (reg:HI 2 y [60])
;         (mem/c:HI (plus:HI (reg/f:HI 3 u)
;                 (const_int 5 [0x5])) [2 %sfp+-3 S2 A8])) yadd2all.c:25# {*movhi_1}
;      (nil))
        ldy     5,u     ;  103  *movhi_1/4      [length = 4]
; (insn# # # (parallel [
;             (set (reg:HI 2 y [60])
;                 (reg:HI 6 d))
;             (set (reg:HI 6 d)
;                 (reg:HI 2 y [60]))
;         ]) yadd2all.c:25# {swaphi}
;      (nil))
        exg     d,y     ;  116  swaphi  [length = 2]
; (insn# # # (set (reg:HI 6 d)
;         (plus:HI (reg:HI 6 d)
;             (mem/c:HI (reg/f:HI 3 u) [2 %sfp+-8 S2 A8]))) yadd2all.c:25# {addhi3}
;      (nil))
        addd    ,u      ;  117  addhi3/3        [length = 4]
; (insn# # # (parallel [
;             (set (reg:HI 2 y [60])
;                 (reg:HI 6 d))
;             (set (reg:HI 6 d)
;                 (reg:HI 2 y [60]))
;         ]) yadd2all.c:25# {swaphi}
;      (expr_list:REG_UNUSED (reg:HI 6 d)
;         (nil)))
        exg     d,y     ;  118  swaphi  [length = 2]
; (insn# # # (set (reg:HI 1 x)
;         (reg:HI 6 d [60])) yadd2all.c:18# {*movhi_1}
;      (expr_list:REG_DEAD (reg:HI 2 y [60])
;         (nil)))
        tfr     d,x     ;  42   *movhi_1/3      [length = 2]
; (insn# # # (set (reg:QI 6 d)
;         (const_int 38 [0x26])) yadd2all.c:18# {movqi}
;      (nil))
        ldb     #38     ;  43   movqi/4 [length = 4]
; (call_insn# # # (call (mem:HI (symbol_ref:HI ("ShowHex") <function_decl # ShowHex>) [0 S2 A8])
;         (const_int 0 [0])) yadd2all.c:18# {*call_pic}
;      (expr_list:REG_DEAD (reg:QI 6 d)
;         (expr_list:REG_DEAD (reg:HI 1 x)
;             (expr_list:REG_EH_REGION (const_int 0 [0])
;                 (nil))))
;     (expr_list:REG_DEP_TRUE (use (reg:QI 6 d))
;         (expr_list:REG_DEP_TRUE (use (reg:HI 1 x))
;             (nil))))
        lbsr    #_ShowHex       ;  44   *call_pic       [length = 4]

GOOD IN 202r.ce3:   42  x <- y [60] GOOD

BAD IN 204r.cprop_hardreg:  42 x <- d BAD

============= 202 GOOD ==========


(insn 103 40 116 3 (set (reg:HI 2 y [60])
        (mem/c:HI (plus:HI (reg/f:HI 3 u)
                (const_int 5 [0x5])) [2 %sfp+-3 S2 A8])) yadd2all.c:25 10 {*movhi_1}
     (nil))

(insn 116 103 117 3 (parallel [
            (set (reg:HI 2 y [60])
                (reg:HI 6 d))
            (set (reg:HI 6 d)
                (reg:HI 2 y [60]))
        ]) yadd2all.c:25 18 {swaphi}
     (nil))

(insn 117 116 118 3 (set (reg:HI 6 d)
        (plus:HI (reg:HI 6 d)
            (mem/c:HI (reg/f:HI 3 u) [2 %sfp+-8 S2 A8]))) yadd2all.c:25 26 {addhi3}
     (nil))

(insn 118 117 42 3 (parallel [
            (set (reg:HI 2 y [60])
                (reg:HI 6 d))
            (set (reg:HI 6 d)
                (reg:HI 2 y [60]))
        ]) yadd2all.c:25 18 {swaphi}
     (expr_list:REG_UNUSED (reg:HI 6 d)
        (nil)))

(insn 42 118 43 3 (set (reg:HI 1 x)
        (reg:HI 2 y [60])) yadd2all.c:18 10 {*movhi_1}
     (expr_list:REG_DEAD (reg:HI 2 y [60])
        (nil)))

(insn 43 42 44 3 (set (reg:QI 6 d)
        (const_int 38 [0x26])) yadd2all.c:18 17 {movqi}
     (nil))

(call_insn 44 43 104 3 (call (mem:HI (symbol_ref:HI ("ShowHex")  <function_decl 0x7f60cae33500 ShowHex>) [0 S2 A8])
        (const_int 0 [0])) yadd2all.c:18 75 {*call_pic}
     (expr_list:REG_DEAD (reg:QI 6 d)
        (expr_list:REG_DEAD (reg:HI 1 x)
            (expr_list:REG_EH_REGION (const_int 0 [0])
                (nil))))
    (expr_list:REG_DEP_TRUE (use (reg:QI 6 d))
        (expr_list:REG_DEP_TRUE (use (reg:HI 1 x))
            (nil))))

================ 204 BAD ================

(insn 103 40 116 3 (set (reg:HI 2 y [60])
        (mem/c:HI (plus:HI (reg/f:HI 3 u)
                (const_int 5 [0x5])) [2 %sfp+-3 S2 A8])) yadd2all.c:25 10 {*movhi_1}
     (nil))

(insn 116 103 117 3 (parallel [
            (set (reg:HI 2 y [60])
                (reg:HI 6 d))
            (set (reg:HI 6 d)
                (reg:HI 2 y [60]))
        ]) yadd2all.c:25 18 {swaphi}
     (nil))

(insn 117 116 118 3 (set (reg:HI 6 d)
        (plus:HI (reg:HI 6 d)
            (mem/c:HI (reg/f:HI 3 u) [2 %sfp+-8 S2 A8]))) yadd2all.c:25 26 {addhi3}
     (nil))

(insn 118 117 42 3 (parallel [
            (set (reg:HI 2 y [60])
                (reg:HI 6 d))
            (set (reg:HI 6 d)
                (reg:HI 2 y [60]))
        ]) yadd2all.c:25 18 {swaphi}
     (expr_list:REG_UNUSED (reg:HI 6 d)
        (nil)))

(insn 42 118 43 3 (set (reg:HI 1 x)
        (reg:HI 6 d [60])) yadd2all.c:18 10 {*movhi_1}
     (expr_list:REG_DEAD (reg:HI 2 y [60])
        (nil)))

(insn 43 42 44 3 (set (reg:QI 6 d)
        (const_int 38 [0x26])) yadd2all.c:18 17 {movqi}
     (nil))

(call_insn 44 43 104 3 (call (mem:HI (symbol_ref:HI ("ShowHex")  <function_decl 0x7f60cae33500 ShowHex>) [0 S2 A8])
        (const_int 0 [0])) yadd2all.c:18 75 {*call_pic}
     (expr_list:REG_DEAD (reg:QI 6 d)
        (expr_list:REG_DEAD (reg:HI 1 x)
            (expr_list:REG_EH_REGION (const_int 0 [0])
                (nil))))
    (expr_list:REG_DEP_TRUE (use (reg:QI 6 d))
        (expr_list:REG_DEP_TRUE (use (reg:HI 1 x))
            (nil))))

================   DIFF  202 204  ==================================


(insn 42 118 43 3 (set (reg:HI 1 x)                                (insn 42 118 43 3 (set (reg:HI 1 x)
        (reg:HI 2 y [60])) yadd2all.c:18 10 {*movhi_1}              |                (reg:HI 6 d [60])) yadd2all.c:18 10 {*movhi_1}
     (expr_list:REG_DEAD (reg:HI 2 y [60])                             (expr_list:REG_DEAD (reg:HI 2 y [60])
        (nil)))                                                                (nil)))

===================================================================
(unless otherwise marked) Copyright 2002-2014 YakPeople. All rights reserved.
(last modified 2023-01-22)       [Login]
(No back references.)