arch-arm, cpu: fix ARM ubsan build on GCC 7.4.0
authorCiro Santilli <ciro.santilli@arm.com>
Tue, 23 Jul 2019 09:32:52 +0000 (10:32 +0100)
committerCiro Santilli <ciro.santilli@arm.com>
Wed, 21 Aug 2019 12:17:17 +0000 (12:17 +0000)
In src/cpu/reg_class.hh, numPinnedWrites was unset because the
constructors were not well factored out.

Change-Id: Ib2fc8d34a1adf5c48826d257a31dd24dfa64a08a
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/20048
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/arch/arm/isa/formats/fp.isa
src/arch/generic/types.hh
src/cpu/reg_class.hh

index 434a69c3295d298158e4906574ffb44ae6003a56..a87988f141f50f1e1fb7ccbaad68e82c75a6d314 100644 (file)
@@ -2077,6 +2077,7 @@ let {{
                 case 0x1: cond = COND_VS; break;
                 case 0x2: cond = COND_GE; break;
                 case 0x3: cond = COND_GT; break;
+                default: panic("unreachable");
                 }
                 if (size == 3) {
                     return new VselD(machInst, vd, vn, vm, cond);
index 353112913eba3042e4793a08f2934d7870f8f9b6..7f9f93f42948a9c6be3097787be4b9a42bddc5b2 100644 (file)
@@ -32,6 +32,7 @@
 #define __ARCH_GENERIC_TYPES_HH__
 
 #include <iostream>
+#include <limits>
 
 #include "base/trace.hh"
 #include "base/types.hh"
@@ -43,6 +44,9 @@ typedef uint16_t RegIndex;
 /** Logical vector register elem index type. */
 using ElemIndex = uint16_t;
 
+/** ElemIndex value that indicates that the register is not a vector. */
+#define ILLEGAL_ELEM_INDEX std::numeric_limits<ElemIndex>::max()
+
 namespace GenericISA
 {
 
index bd49d15b03466cb52e7031812020ad0d309aea82..e71e938bf1e5d0d4abbab52b9161ce883949fd9c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016-2018 ARM Limited
+ * Copyright (c) 2016-2019 ARM Limited
  * All rights reserved
  *
  * The license below extends only to copyright in the software and shall
@@ -88,21 +88,21 @@ class RegId {
     friend struct std::hash<RegId>;
 
   public:
-    RegId() : regClass(IntRegClass), regIdx(0), elemIdx(-1) {}
+    RegId() : RegId(IntRegClass, 0) {}
+
     RegId(RegClass reg_class, RegIndex reg_idx)
-        : regClass(reg_class), regIdx(reg_idx), elemIdx(-1),
-          numPinnedWrites(0)
-    {
-        panic_if(regClass == VecElemClass,
-                "Creating vector physical index w/o element index");
-    }
+        : RegId(reg_class, reg_idx, ILLEGAL_ELEM_INDEX) {}
 
     explicit RegId(RegClass reg_class, RegIndex reg_idx, ElemIndex elem_idx)
         : regClass(reg_class), regIdx(reg_idx), elemIdx(elem_idx),
-          numPinnedWrites(0)
-    {
-        panic_if(regClass != VecElemClass,
-                "Creating non-vector physical index w/ element index");
+          numPinnedWrites(0) {
+        if (elemIdx == ILLEGAL_ELEM_INDEX) {
+            panic_if(regClass == VecElemClass,
+                    "Creating vector physical index w/o element index");
+        } else {
+            panic_if(regClass != VecElemClass,
+                    "Creating non-vector physical index w/ element index");
+        }
     }
 
     bool operator==(const RegId& that) const {