Fix SConstruct for asan build
authorEarl Ou <shunhsingou@google.com>
Fri, 7 Sep 2018 07:16:53 +0000 (15:16 +0800)
committerEarl Ou <shunhsingou@google.com>
Thu, 13 Sep 2018 13:57:46 +0000 (13:57 +0000)
Sometimes it's easier to debug gem5 built with ASan enabled. This CL fixes
some build error when using --with-asan.

Bug: None
Test: ./scripts/build_gem5 --with-asan --with-ubsan build/ARM/gem5.debug

Change-Id: Iaaaaebc3f25749e11f97bf454ddd0153b3de56e7
Reviewed-on: https://gem5-review.googlesource.com/12511
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Reviewed-by: Anthony Gutierrez <anthony.gutierrez@amd.com>
Maintainer: Anthony Gutierrez <anthony.gutierrez@amd.com>

SConstruct
src/arch/arm/isa.hh
src/cpu/reg_class.hh

index 79522e46f8a5d67b8e04bfc45075422e18bca006..f689b556a6140ababc94e2e0965ad0cbe3c42608 100755 (executable)
@@ -484,11 +484,11 @@ if main['GCC']:
                 compareVersions(main['GCC_VERSION'], '4.9') >= 0:
             main.Append(CCFLAGS=['-fsanitize=address,undefined',
                                  '-fno-omit-frame-pointer'],
-                       LINKFLAGS='-fsanitize=address,undefined')
+                        LINKFLAGS='-fsanitize=address,undefined')
         else:
             main.Append(CCFLAGS=['-fsanitize=address',
                                  '-fno-omit-frame-pointer'],
-                       LINKFLAGS='-fsanitize=address')
+                        LINKFLAGS='-fsanitize=address')
     # Only gcc >= 4.9 supports UBSan, so check both the version
     # and the command-line option before adding the compiler and
     # linker flags.
@@ -541,16 +541,16 @@ elif main['CLANG']:
     # versions here.
     if GetOption('with_ubsan'):
         if GetOption('with_asan'):
-            env.Append(CCFLAGS=['-fsanitize=address,undefined',
-                                '-fno-omit-frame-pointer'],
+            main.Append(CCFLAGS=['-fsanitize=address,undefined',
+                                 '-fno-omit-frame-pointer'],
                        LINKFLAGS='-fsanitize=address,undefined')
         else:
-            env.Append(CCFLAGS='-fsanitize=undefined',
-                       LINKFLAGS='-fsanitize=undefined')
+            main.Append(CCFLAGS='-fsanitize=undefined',
+                        LINKFLAGS='-fsanitize=undefined')
 
     elif GetOption('with_asan'):
-        env.Append(CCFLAGS=['-fsanitize=address',
-                            '-fno-omit-frame-pointer'],
+        main.Append(CCFLAGS=['-fsanitize=address',
+                             '-fno-omit-frame-pointer'],
                    LINKFLAGS='-fsanitize=address')
 
 else:
index 0521c43f905f5dc97a995ad3ef4887796be466ff..7b39682f9810493379e699dbf2cfd7e82b81171d 100644 (file)
@@ -461,7 +461,7 @@ namespace ArmISA
                     return INTREG_SP0;
                   default:
                     panic("Invalid exception level");
-                    break;
+                    return 0;  // Never happens.
                 }
             } else {
                 return flattenIntRegModeIndex(reg);
index 617d17e35dcdd8534c1ccdc4fdbc38ffc0195a2a..69da9cf7ea4352d201b2484caba32dd25bab8c59 100644 (file)
@@ -84,7 +84,7 @@ class RegId {
     static constexpr size_t Scale = TheISA::NumVecElemPerVecReg;
     friend struct std::hash<RegId>;
   public:
-    RegId() {};
+    RegId() : regClass(IntRegClass), regIdx(0), elemIdx(-1) {}
     RegId(RegClass reg_class, RegIndex reg_idx)
         : regClass(reg_class), regIdx(reg_idx), elemIdx(-1)
     {