[llvm-commits] [compiler-rt] r157560 - /compiler-rt/trunk/lib/profile/GCDAProfiling.c

Bill Wendling isanbard at gmail.com
Sun May 27 19:50:53 PDT 2012


Author: void
Date: Sun May 27 21:50:53 2012
New Revision: 157560

URL: http://llvm.org/viewvc/llvm-project?rev=157560&view=rev
Log:
Don't use 'strrchr', which isn't implemented here yet.

Modified:
    compiler-rt/trunk/lib/profile/GCDAProfiling.c

Modified: compiler-rt/trunk/lib/profile/GCDAProfiling.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/GCDAProfiling.c?rev=157560&r1=157559&r2=157560&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/GCDAProfiling.c (original)
+++ compiler-rt/trunk/lib/profile/GCDAProfiling.c Sun May 27 21:50:53 2012
@@ -117,12 +117,20 @@
   output_file = fopen(filename, "w+b");
 
   if (!output_file) {
-    const char *cptr = strrchr(orig_filename, '/');
-    output_file = fopen(cptr ? cptr + 1 : orig_filename, "w+b");
+    int len = strlen(orig_filename) - 1;
+
+    for (; len >= 0 && orig_filename[len] != '/'; --len)
+      /* empty */;
+
+    if (len < 0)
+      len = 0;
+    else if (orig_filename[len] == '/')
+      ++len;
+
+    output_file = fopen(&orig_filename[len], "w+b");
 
     if (!output_file) {
-      fprintf(stderr, "profiling:%s: cannot open\n",
-              cptr ? cptr + 1 : orig_filename);
+      fprintf(stderr, "profiling:%s: cannot open\n", &orig_filename[len]);
       return;
     }
   }
@@ -160,8 +168,9 @@
     ++*counter;
 #ifdef DEBUG_GCDAPROFILING
   else
-    printf("llvmgcda: increment_indirect_counter counters=%x, pred=%u\n",
-           state_table_row, *predecessor);
+    fprintf(stderr,
+            "llvmgcda: increment_indirect_counter counters=%x, pred=%u\n",
+            state_table_row, *predecessor);
 #endif
 }
 





More information about the llvm-commits mailing list