]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
sim: frv: fix cmpb uninitialized variable usage
authorMike Frysinger <vapier@gentoo.org>
Sun, 24 Dec 2023 10:21:30 +0000 (05:21 -0500)
committerMike Frysinger <vapier@gentoo.org>
Mon, 1 Jan 2024 15:56:08 +0000 (10:56 -0500)
This code sets up the cc variable based on the comparison of other
registers, but it does so incrementally with bit operations, and it
never initializes the cc variable.  Initialize it to 0 which the
cmpba insn is already doing.

cpu/frv.cpu
sim/frv/sem.c

index cdb169eddc1c11d99df72a32e14f86e6d07de391..d2fe7c602cc320d8a528dec7e4076968371e30c7 100644 (file)
      "cmpb$pack $GRi,$GRj,$ICCi_1"
      (+ pack (GRk-null) OP_00 GRi ICCi_1 OPE2_0C GRj)
      (sequence ((QI cc))
+              (set cc 0)
               (set-n cc (eq (and GRi #xff000000) (and GRj #xff000000)))
               (set-z cc (eq (and GRi #x00ff0000) (and GRj #x00ff0000)))
               (set-v cc (eq (and GRi #x0000ff00) (and GRj #x0000ff00)))
index 20ac47be764206f6dbd2025b7306cf92f287edd6..cf47aff7c39bba38fe688474b07e1cc51eb76449 100644 (file)
@@ -3055,6 +3055,7 @@ SEM_FN_NAME (frvbf,cmpb) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
 
 {
   QI tmp_cc;
+  tmp_cc = 0;
 if (EQBI (EQSI (ANDSI (GET_H_GR (FLD (f_GRi)), 0xff000000), ANDSI (GET_H_GR (FLD (f_GRj)), 0xff000000)), 0)) {
   tmp_cc = ANDQI (tmp_cc, 7);
 } else {