summaryrefslogtreecommitdiffstats
path: root/contrib/gcc/coverage.c
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2013-12-15 03:47:31 +0000
committerpfg <pfg@FreeBSD.org>2013-12-15 03:47:31 +0000
commit81b52978780f8e031af44e70e553b7b8c7146659 (patch)
treeac6cf6b38fa03b3fe833b7fed287d281e90a822e /contrib/gcc/coverage.c
parent452ca0b4a4cc660ea49c3719436eebd4fe78b787 (diff)
downloadFreeBSD-src-81b52978780f8e031af44e70e553b7b8c7146659.zip
FreeBSD-src-81b52978780f8e031af44e70e553b7b8c7146659.tar.gz
MFC rr258501, r258507;
gcc: Bring updates from Google's enhanced gcc-4.2.1. Google released and enhanced version of gcc-4.2.1 plus their local patches for Android[1]. The patches are owned by Google and the license hasn't been changed from the original GPLv2. We are only bringing a subset of the available patches that may be helpful in FreeBSD, in other words, changes specific to android are not included. From the README.google file[1]. Patches applied to google_vendor_src_branch/gcc/gcc-4.2.1: gcc/Makefile.in gcc/c-common.c gcc/c-common.h gcc/c-opts.c gcc/c-typeck.c gcc/cp/typeck.c gcc/doc/invoke.texi gcc/flags.h gcc/opts.c gcc/tree-flow.h gcc/tree-ssa-alias-warnings.c gcc/tree-ssa-alias.c Backport of -Wstrict-aliasing from mainline. Silvius Rus <rus@google.com> gcc/coverage.c: Patch coverage_checksum_string for PR 25351. Seongbae Park <spark@google.com> Not yet submitted to FSF. gcc/c-opts.c gcc/c-ppoutput.c gcc/c.opt gcc/doc/cppopts.texi libcpp/Makefile.in libcpp/directives-only.c libcpp/directives.c libcpp/files.c libcpp/include/cpplib.h libcpp/init.c libcpp/internal.h libcpp/macro.c Support for -fdirectives-only. Ollie Wild <aaw@google.com>. Submitted to FSF but not yet approved. libstdc++-v3/include/ext/hashtable.h http://b/742065 http://b/629994 Reduce min size of hashtable for hash_map, hash_set from 53 to 5 libstdc++-v3/include/ext/hashtable.h http://b/629994 Do not iterate over buckets if hashtable is empty. gcc/common.opt gcc/doc/invoke.texi gcc/flags.h gcc/gimplify.c gcc/opts.c Add Saito's patch for -finstrument-functions-exclude-* options. gcc/common.opt gcc/doc/invoke.texi gcc/final.c gcc/flags.h gcc/opts.c gcc/testsuite/gcc.dg/Wframe-larger-than.c Add a new flag -Wframe-larger-than- which enables a new warning when a frame size of a function is larger than specified. This patch hasn't been integrated into gcc mainline yet. gcc/tree-vrp.c Add a hack to avoid using ivopts information for pointers starting at constant values. Reference: [1] https://android.googlesource.com/toolchain/gcc/+/master/gcc-4.2.1/ Obtained from: Google Inc.
Diffstat (limited to 'contrib/gcc/coverage.c')
-rw-r--r--contrib/gcc/coverage.c100
1 files changed, 59 insertions, 41 deletions
diff --git a/contrib/gcc/coverage.c b/contrib/gcc/coverage.c
index 5eaf488..101c2ac 100644
--- a/contrib/gcc/coverage.c
+++ b/contrib/gcc/coverage.c
@@ -429,57 +429,75 @@ tree_coverage_counter_ref (unsigned counter, unsigned no)
static unsigned
coverage_checksum_string (unsigned chksum, const char *string)
{
- int i;
char *dup = NULL;
+ char *ptr;
/* Look for everything that looks if it were produced by
get_file_function_name_long and zero out the second part
that may result from flag_random_seed. This is not critical
as the checksums are used only for sanity checking. */
- for (i = 0; string[i]; i++)
+#define GLOBAL_PREFIX "_GLOBAL__"
+#define TRAILING_N "N_"
+#define ISCAPXDIGIT(a) (((a) >= '0' && (a) <= '9') || ((a) >= 'A' && (a) <= 'F'))
+ if ((ptr = strstr (string, GLOBAL_PREFIX)))
{
- int offset = 0;
- if (!strncmp (string + i, "_GLOBAL__N_", 11))
- offset = 11;
- if (!strncmp (string + i, "_GLOBAL__", 9))
- offset = 9;
-
- /* C++ namespaces do have scheme:
- _GLOBAL__N_<filename>_<wrongmagicnumber>_<magicnumber>functionname
- since filename might contain extra underscores there seems
- to be no better chance then walk all possible offsets looking
- for magicnuber. */
- if (offset)
- {
- for (i = i + offset; string[i]; i++)
- if (string[i]=='_')
- {
- int y;
-
- for (y = 1; y < 9; y++)
- if (!(string[i + y] >= '0' && string[i + y] <= '9')
- && !(string[i + y] >= 'A' && string[i + y] <= 'F'))
- break;
- if (y != 9 || string[i + 9] != '_')
- continue;
- for (y = 10; y < 18; y++)
- if (!(string[i + y] >= '0' && string[i + y] <= '9')
- && !(string[i + y] >= 'A' && string[i + y] <= 'F'))
- break;
- if (y != 18)
- continue;
- if (!dup)
- string = dup = xstrdup (string);
- for (y = 10; y < 18; y++)
- dup[i + y] = '0';
- }
- break;
- }
+ /* Skip _GLOBAL__. */
+ ptr += strlen (GLOBAL_PREFIX);
+
+ /* Skip optional N_ (in case __GLOBAL_N__). */
+ if (!strncmp (ptr, TRAILING_N, strlen (TRAILING_N)))
+ ptr += strlen (TRAILING_N);
+ /* At this point, ptr should point after "_GLOBAL__N_" or "_GLOBAL__". */
+
+ while ((ptr = strchr (ptr, '_')) != NULL)
+ {
+ int y;
+ /* For every "_" in the rest of the string,
+ try the follwing pattern matching */
+
+ /* Skip over '_'. */
+ ptr++;
+#define NDIGITS (8)
+ /* Try matching the pattern:
+ <8-digit hex>_<8-digit hex>
+ The second number is randomly generated
+ so we want to mask it out before computing the checksum. */
+ for (y = 0; *ptr != 0 && y < NDIGITS; y++, ptr++)
+ if (!ISCAPXDIGIT (*ptr))
+ break;
+ if (y != NDIGITS || *ptr != '_')
+ continue;
+ /* Skip over '_' again. */
+ ptr++;
+ for (y = 0; *ptr != 0 && y < NDIGITS; y++, ptr++)
+ if (!ISCAPXDIGIT (*ptr))
+ break;
+
+ if (y == NDIGITS)
+ {
+ /* We have a match.
+ Duplicate the string and mask out
+ the second 8-digit number. */
+ dup = xstrdup (string);
+ ptr = dup + (ptr - string);
+ for(y = -NDIGITS - 1 ; y < 0; y++)
+ {
+ ptr[y] = '0';
+ }
+ ptr = dup;
+ break;
+ }
+ }
+ /* "ptr" should be NULL if we couldn't find the match
+ (strchr will return NULL if no match is found),
+ or it should point to dup which contains the string
+ with the random part masked. */
}
- chksum = crc32_string (chksum, string);
+ chksum = crc32_string (chksum, (ptr) ? ptr : string);
+
if (dup)
- free (dup);
+ free (dup);
return chksum;
}
OpenPOWER on IntegriCloud