[llvm-commits] [parallel] CVS: llvm/runtime/libprofile/BlockProfiling.c CommonProfiling.c FunctionProfiling.c Profiling.h

Misha Brukman brukman at cs.uiuc.edu
Mon Mar 1 18:10:00 PST 2004


Changes in directory llvm/runtime/libprofile:

BlockProfiling.c updated: 1.1 -> 1.1.4.1
CommonProfiling.c updated: 1.3 -> 1.3.4.1
FunctionProfiling.c updated: 1.1 -> 1.1.4.1
Profiling.h updated: 1.1 -> 1.1.4.1

---
Log message:

Merge from trunk

---
Diffs of the changes:  (+43 -11)

Index: llvm/runtime/libprofile/BlockProfiling.c
diff -u llvm/runtime/libprofile/BlockProfiling.c:1.1 llvm/runtime/libprofile/BlockProfiling.c:1.1.4.1
--- llvm/runtime/libprofile/BlockProfiling.c:1.1	Tue Oct 28 12:56:51 2003
+++ llvm/runtime/libprofile/BlockProfiling.c	Mon Mar  1 17:58:47 2004
@@ -34,10 +34,11 @@
 /* llvm_start_block_profiling - This is the main entry point of the block
  * profiling library.  It is responsible for setting up the atexit handler.
  */
-void llvm_start_block_profiling(int argc, const char **argv,
-                                unsigned *arrayStart, unsigned numElements) {
-  save_arguments(argc, argv);
+int llvm_start_block_profiling(int argc, const char **argv,
+                               unsigned *arrayStart, unsigned numElements) {
+  int Ret = save_arguments(argc, argv);
   ArrayStart = arrayStart;
   NumElements = numElements;
   atexit(BlockProfAtExitHandler);
+  return Ret;
 }


Index: llvm/runtime/libprofile/CommonProfiling.c
diff -u llvm/runtime/libprofile/CommonProfiling.c:1.3 llvm/runtime/libprofile/CommonProfiling.c:1.3.4.1
--- llvm/runtime/libprofile/CommonProfiling.c:1.3	Tue Oct 28 16:45:25 2003
+++ llvm/runtime/libprofile/CommonProfiling.c	Mon Mar  1 17:58:47 2004
@@ -24,12 +24,38 @@
 static char *SavedArgs = 0;
 static unsigned SavedArgsLength = 0;
 
+static const char *OutputFilename = "llvmprof.out";
+
 /* save_arguments - Save argc and argv as passed into the program for the file
  * we output.
  */
-void save_arguments(int argc, const char **argv) {
+int save_arguments(int argc, const char **argv) {
   unsigned Length, i;
-  if (SavedArgs || !argv) return;  /* This can be called multiple times */
+  if (SavedArgs || !argv) return argc;  /* This can be called multiple times */
+
+  /* Check to see if there are any arguments passed into the program for the
+   * profiler.  If there are, strip them off and remember their settings.
+   */
+  while (argc > 1 && !strncmp(argv[1], "-llvmprof-", 10)) {
+    /* Ok, we have an llvmprof argument.  Remove it from the arg list and decide
+     * what to do with it.
+     */
+    const char *Arg = argv[1];
+    memmove(&argv[1], &argv[2], (argc-1)*sizeof(char*));
+    --argc;
+
+    if (!strcmp(Arg, "-llvmprof-output")) {
+      if (argc == 1)
+        puts("-llvmprof-output requires a filename argument!");
+      else {
+        OutputFilename = strdup(argv[1]);
+        memmove(&argv[1], &argv[2], (argc-1)*sizeof(char*));
+        --argc;
+      }
+    } else {
+      printf("Unknown option to the profiler runtime: '%s' - ignored.\n", Arg);
+    }
+  }
 
   for (Length = 0, i = 0; i != (unsigned)argc; ++i)
     Length += strlen(argv[i])+1;
@@ -43,6 +69,8 @@
   }
 
   SavedArgsLength = Length;
+
+  return argc;
 }
 
 
@@ -61,9 +89,11 @@
    */
   if (OutFile == -1) {
     off_t Offset;
-    OutFile = open("llvmprof.out", O_CREAT | O_WRONLY | O_APPEND, 0666);
+    OutFile = open(OutputFilename, O_CREAT | O_WRONLY | O_APPEND, 0666);
     if (OutFile == -1) {
-      perror("LLVM profiling: while opening 'llvmprof.out'");
+      fprintf(stderr, "LLVM profiling runtime: while opening '%s': ",
+              OutputFilename);
+      perror("");
       return;
     }
 


Index: llvm/runtime/libprofile/FunctionProfiling.c
diff -u llvm/runtime/libprofile/FunctionProfiling.c:1.1 llvm/runtime/libprofile/FunctionProfiling.c:1.1.4.1
--- llvm/runtime/libprofile/FunctionProfiling.c:1.1	Tue Oct 28 12:56:51 2003
+++ llvm/runtime/libprofile/FunctionProfiling.c	Mon Mar  1 17:58:47 2004
@@ -32,10 +32,11 @@
 /* llvm_start_func_profiling - This is the main entry point of the function
  * profiling library.  It is responsible for setting up the atexit handler.
  */
-void llvm_start_func_profiling(int argc, const char **argv,
-                               unsigned *arrayStart, unsigned numElements) {
-  save_arguments(argc, argv);
+int llvm_start_func_profiling(int argc, const char **argv,
+                              unsigned *arrayStart, unsigned numElements) {
+  int Ret = save_arguments(argc, argv);
   ArrayStart = arrayStart;
   NumElements = numElements;
   atexit(FuncProfAtExitHandler);
+  return Ret;
 }


Index: llvm/runtime/libprofile/Profiling.h
diff -u llvm/runtime/libprofile/Profiling.h:1.1 llvm/runtime/libprofile/Profiling.h:1.1.4.1
--- llvm/runtime/libprofile/Profiling.h:1.1	Tue Oct 28 12:56:51 2003
+++ llvm/runtime/libprofile/Profiling.h	Mon Mar  1 17:58:47 2004
@@ -18,7 +18,7 @@
 /* save_arguments - Save argc and argv as passed into the program for the file
  * we output.
  */
-void save_arguments(int argc, const char **argv);
+int save_arguments(int argc, const char **argv);
 
 enum ProfilingType {
   Arguments = 1,   /* The command line argument block */





More information about the llvm-commits mailing list