[llvm-commits] CVS: llvm/test/Regression/Reoptimizer/inst/Makefile Test1.c

Joel Stanley jstanley at cs.uiuc.edu
Wed Apr 30 17:12:01 PDT 2003


Changes in directory llvm/test/Regression/Reoptimizer/inst:

Makefile updated: 1.1 -> 1.2
Test1.c updated: 1.1 -> 1.2

---
Log message:



---
Diffs of the changes:

Index: llvm/test/Regression/Reoptimizer/inst/Makefile
diff -u llvm/test/Regression/Reoptimizer/inst/Makefile:1.1 llvm/test/Regression/Reoptimizer/inst/Makefile:1.2
--- llvm/test/Regression/Reoptimizer/inst/Makefile:1.1	Fri Apr  4 16:57:00 2003
+++ llvm/test/Regression/Reoptimizer/inst/Makefile	Wed Apr 30 17:17:37 2003
@@ -1,8 +1,8 @@
 LEVEL = ../../../..
 
-PERFOBJS = $(LEVEL)/lib/Debug/perfinst.o \
-           $(LEVEL)/lib/Reoptimizer/BinInterface/Debug/sparcdis.o \
-           $(LEVEL)/lib/Reoptimizer/BinInterface/Debug/sparc9.o
+PERFOBJS = $(LEVEL)/lib/Debug/libperfinst.a     \
+	   $(LEVEL)/lib/Debug/libtracecache.a   \
+	   $(LEVEL)/lib/Debug/libbininterface.a
 
 Test1: Test1.o $(PERFOBJS)
 	/usr/dcs/software/evaluation/bin/g++ -o Test1 Test1.o $(PERFOBJS) -lelf
@@ -15,7 +15,7 @@
 
 Test1.opt.bc: Test1.bc
 	opt -load $(LEVEL)/lib/Debug/libperf.so -pp1 -emitfuncs -deadtypeelim < Test1.bc > Test1.opt.o
-	llvm-gcc Test1.opt.o -o Test1.opt
+	llvm-gcc -Wl,-disable-internalize Test1.opt.o -o Test1.opt
 
 Test1.bc: Test1.c
 	llvm-gcc -c Test1.c -o Test1.bc


Index: llvm/test/Regression/Reoptimizer/inst/Test1.c
diff -u llvm/test/Regression/Reoptimizer/inst/Test1.c:1.1 llvm/test/Regression/Reoptimizer/inst/Test1.c:1.2
--- llvm/test/Regression/Reoptimizer/inst/Test1.c:1.1	Wed Mar  5 16:01:15 2003
+++ llvm/test/Regression/Reoptimizer/inst/Test1.c	Wed Apr 30 17:17:37 2003
@@ -1,15 +1,67 @@
+// begin includes for rtl, etc...
+
+#include <sys/time.h>
+
+// RTL functions && sigfun protos
+extern void doAbsolutelyNothing();
+
+long     pp_timestamp(void);
+double   pp_elapsed_time_start(void);
+double   pp_elapsed_time_end(double* start);
+unsigned pp_counterPrim(void);
+void     pp_regionPair(void*, void*);
+void     pp_metricSpec(void*);
+
+// implementations of RTL stuff, etc
+
+double pp_elapsed_time_start(void) 
+{
+    struct timeval tv;
+    gettimeofday(&tv, 0);
+
+    // return result in ms
+    return (tv.tv_sec * 1000000 + tv.tv_usec) / 1000.0;
+}
+
+double pp_elapsed_time_end(double* start) 
+{
+    struct timeval tv;
+    double end;
+
+    gettimeofday(&tv, 0);
+    end = (tv.tv_sec * 1000000 + tv.tv_usec) / 1000.0; // convert to ms
+    return end - *start;                               // compute diff & return
+}
+
+// Begin user source file!
+
+// The following is actually the semantic result of processing a metric declaration (need
+// more sigfun support)
+
+double elapsedTime = 0;
+
 #include <stdio.h>
 
-void phase2(int methodNum);
+//extern "C" void phase2();
+void phase2();
+
+int fib(int n);
+void fibs();
+
+
+void floogle() 
+{
+    printf("this is lame");
+}
 
 int main(int argc, char** argv) 
 {
-    int result;
-    phase2(0);
-    printf("Going to call fib and whatnot...\n");
-    result = fib(5);
-    printf("fib(5) + 1 = %d\n", ++result);
-    return result;
+    phase2();
+
+    printf("Just about to call fibs()...\n");
+    fibs();
+
+    return 0;
 }
 
 int fib(int n) 
@@ -18,4 +70,41 @@
         return n;
     else
         return fib(n-2) + fib(n-1);
+}
+
+void fibs() 
+{
+    int i;
+
+    printf("Inside fibs now, sleeping for 2 seconds...\n");
+    
+    ////////////////
+    // The following is the "scope" that the sampling applies to, represented by
+    // sigfuns. We need better sigfun support so that the phase 1.
+    //
+    // That is, the below should look like:
+    //
+    // pp_region_start(elapsedTime);
+    // <for loop>
+    // pp_region_end(elaspedTime);
+    //
+    // or something similar. We should not be putting the actual invoked functions below,
+    // although the post-phase1 transformed code should be "similar" (calls removed and
+    // volatile loads put in their place, of course!)
+
+    double y = pp_elapsed_time_start();
+    
+    for(i = 10; i > 0; i--) {
+        printf("fib(%d) = %d\n", i, fib(i));
+    }
+
+    printf("after for loop...\n");
+    fflush(stdout);
+
+    elapsedTime = pp_elapsed_time_end(&y);
+    
+    //
+    ////////////////
+
+    printf("Leaving fibs...");
 }





More information about the llvm-commits mailing list