OSDN Git Service

The computation of string length is not that complicated. Fix it, again. :)
authorNick Lewycky <nicholas@mxc.ca>
Thu, 5 May 2011 23:52:18 +0000 (23:52 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Thu, 5 May 2011 23:52:18 +0000 (23:52 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130967 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Instrumentation/GCOVProfiling.cpp
runtime/libprofile/GCDAProfiling.c

index 23427f7..13eecb7 100644 (file)
@@ -140,7 +140,7 @@ namespace {
       // A GCOV string is a length, followed by a NUL, then between 0 and 3 NULs
       // padding out to the next 4-byte word. The length is measured in 4-byte
       // words including padding, not bytes of actual string.
-      return (s.size() + 5) / 4;
+      return (s.size() / 4) + 1;
     }
 
     void writeGCOVString(StringRef s) {
index 8ab4227..5af94be 100644 (file)
@@ -49,7 +49,7 @@ static void write_int64(uint64_t i) {
 }
 
 static uint32_t length_of_string(const char *s) {
-  return (strlen(s) + 5) / 4;
+  return (strlen(s) / 4) + 1;
 }
 
 static void write_string(const char *s) {