]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
sim: profile: fix bucketing with 64-bit targets
authorMike Frysinger <vapier@gentoo.org>
Tue, 12 Jan 2021 10:39:16 +0000 (05:39 -0500)
committerMike Frysinger <vapier@gentoo.org>
Sat, 30 Jan 2021 06:15:04 +0000 (01:15 -0500)
When the target's PC is 64-bits, this shift expands into a range of
8 * 8 - 1 which doesn't work with 32-bit constants.  Force it to be
a 64-bit value all the time and let the compiler truncate it.

sim/common/ChangeLog
sim/common/sim-profile.c

index cafb4b2043282aca3611b21e9a09b81250d82f0b..dbf030d502f6c6aaa7b3c25b70216721b2431908 100644 (file)
@@ -1,3 +1,7 @@
+2021-01-30  Mike Frysinger  <vapier@gentoo.org>
+
+       * sim-profile.c (profile_pc_init): Change 1 in shifts to 1ULL.
+
 2021-01-30  Mike Frysinger  <vapier@gentoo.org>
 
        * sim-hw.c (merge_device_file): Replace fgets with getline.
index f4ce89f0428e97ec43d432561300226687824d57..5508f0f516d6dfe9e7126baa1234729d32d98bd0 100644 (file)
@@ -554,7 +554,7 @@ profile_pc_init (SIM_DESC sd)
                    {
                      /* nr_buckets = (full-address-range / 2) / (bucket_size / 2) */
                      PROFILE_PC_NR_BUCKETS (data) =
-                       ((1 << sizeof (sim_cia) * (8 - 1))
+                       ((1ULL << sizeof (sim_cia) * (8 - 1))
                         / (PROFILE_PC_BUCKET_SIZE (data) / 2));
                    }
                  else
@@ -573,7 +573,7 @@ profile_pc_init (SIM_DESC sd)
            {
              if (PROFILE_PC_END (data) == 0)
                /* bucket_size = (full-address-range / 2) / (nr_buckets / 2) */
-               bucket_size = ((1 << ((sizeof (sim_cia) * 8) - 1))
+               bucket_size = ((1ULL << ((sizeof (sim_cia) * 8) - 1))
                               / (PROFILE_PC_NR_BUCKETS (data) / 2));
              else
                bucket_size = ((PROFILE_PC_END (data)