<commit_before>#!/usr/bin/perl -w
#
# Program:  profile.pl
#
# Synopsis: Insert instrumentation code into a program, run it with the JIT,
#           then print out a profile report.
#
# Syntax:   profile.pl [OPTIONS] bytecodefile <arguments>
#
# OPTIONS may include one or more of the following:
#     NONE SO FAR
#
#


my $ProfilePass = "-insert-function-profiling";

# Parse arguments...
while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
  shift;
  last if /^--$/;  # Stop processing arguments on --

  # List command line options here...
  #if (/^-enable-foo$/)     { $FOO = 1; next; }

  print "Unknown option: $_ : ignoring!\n";
}

die "Must specify LLVM bytecode file as first argument!" if (@ARGV == 0);

my $BytecodeFile = $ARGV[0];

shift @ARGV;

my $LLIPath = `which lli`;
$LLIPath = `dirname $LLIPath`;
chomp $LLIPath;

my $LibProfPath = $LLIPath . "/../../lib/Debug/libprofile_rt.so";

system "opt $ProfilePass < $BytecodeFile | lli -load $LibProfPath - " .
         (join ' ', @ARGV);

system "llvm-prof $BytecodeFile";<commit_msg>Add option for block profiling, pass in the "correct" argv[0] to the program<commit_after>#!/usr/bin/perl -w
#
# Program:  profile.pl
#
# Synopsis: Insert instrumentation code into a program, run it with the JIT,
#           then print out a profile report.
#
# Syntax:   profile.pl [OPTIONS] bytecodefile <arguments>
#
# OPTIONS may include one or more of the following:
#     -block - Enable basic block level profiling
#

my $ProfilePass = "-insert-function-profiling";

# Parse arguments...
while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
  shift;
  last if /^--$/;  # Stop processing arguments on --

  # List command line options here...
  if (/^-block$/) { $ProfilePass = "-insert-block-profiling"; next; }

  print "Unknown option: $_ : ignoring!\n";
}

die "Must specify LLVM bytecode file as first argument!" if (@ARGV == 0);

my $BytecodeFile = $ARGV[0];

shift @ARGV;

my $LLIPath = `which lli`;
$LLIPath = `dirname $LLIPath`;
chomp $LLIPath;

my $LibProfPath = $LLIPath . "/../../lib/Debug/libprofile_rt.so";

system "opt $ProfilePass < $BytecodeFile | lli -fake-argv0 '$BytecodeFile'" .
       " -load $LibProfPath - " . (join ' ', @ARGV);

system "llvm-prof $BytecodeFile";
{'fraction_non_alphanumeric': 0.1637661758143686, 'fraction_numerical': 0.004016064257028112, 'mean_word_length': 3.328185328185328, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6767473', 'n_tokens_mistral': 803, 'n_tokens_neox': 772, 'n_words': 238}