blob: 27bfd7190cdb71ecce8b689ba0bac87fb0b355c6 [file] [log] [blame]
Chris Lattner10c91cc2003-10-28 22:11:31 +00001#!/usr/bin/perl -w
2#
3# Program: profile.pl
4#
5# Synopsis: Insert instrumentation code into a program, run it with the JIT,
6# then print out a profile report.
7#
8# Syntax: profile.pl [OPTIONS] bytecodefile <arguments>
9#
10# OPTIONS may include one or more of the following:
11# NONE SO FAR
12#
13#
14
15
16my $ProfilePass = "-insert-function-profiling";
17
18# Parse arguments...
19while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
20 shift;
21 last if /^--$/; # Stop processing arguments on --
22
23 # List command line options here...
24 #if (/^-enable-foo$/) { $FOO = 1; next; }
25
26 print "Unknown option: $_ : ignoring!\n";
27}
28
29die "Must specify LLVM bytecode file as first argument!" if (@ARGV == 0);
30
31my $BytecodeFile = $ARGV[0];
32
33shift @ARGV;
34
35my $LLIPath = `which lli`;
36$LLIPath = `dirname $LLIPath`;
37chomp $LLIPath;
38
39my $LibProfPath = $LLIPath . "/../../lib/Debug/libprofile_rt.so";
40
41system "opt $ProfilePass < $BytecodeFile | lli -load $LibProfPath - " .
42 (join ' ', @ARGV);
43
44system "llvm-prof $BytecodeFile";