[llvm-commits] [parallel] CVS: llvm/utils/llvm-native-gxx NightlyTest.gnuplot check-each-file getsrcs.sh llvm-native-gcc profile.pl

Misha Brukman brukman at cs.uiuc.edu
Mon Mar 1 20:28:11 PST 2004


Changes in directory llvm/utils:

llvm-native-gxx added (r1.1.2.1)
NightlyTest.gnuplot updated: 1.8 -> 1.8.2.1
check-each-file updated: 1.1 -> 1.1.2.1
getsrcs.sh updated: 1.12 -> 1.12.6.1
llvm-native-gcc updated: 1.1 -> 1.1.4.1
profile.pl updated: 1.4 -> 1.4.4.1

---
Log message:

Merge from trunk

---
Diffs of the changes:  (+281 -13)

Index: llvm/utils/llvm-native-gxx
diff -c /dev/null llvm/utils/llvm-native-gxx:1.1.2.1
*** /dev/null	Mon Mar  1 17:59:35 2004
--- llvm/utils/llvm-native-gxx	Mon Mar  1 17:59:25 2004
***************
*** 0 ****
--- 1,249 ----
+ #!/usr/bin/perl
+ # Wrapper around LLVM tools to generate a native .o from llvm-gxx using an
+ # LLVM back-end (CBE by default).
+ 
+ # set up defaults.
+ $Verbose = 0;
+ $SaveTemps = 1;
+ $PreprocessOnly = 0;
+ $CompileDontLink = 0;
+ $Backend = 'cbe';
+ chomp ($ProgramName = `basename $0`);
+ 
+ sub boldprint {
+ 	print "", @_, "";
+ }
+ 
+ # process command-line options.
+ # most of these are passed on to llvm-gxx.
+ $GCCOptions = "";
+ for ($i = 0; $i <= $#ARGV; ++$i) {	
+ 	if ($ARGV[$i] =~ /-mllvm-backend=([a-z0-9]*)/) {
+ 		$Backend = $1;
+ 		if ($ProgramName =~ /llvm-native-gxx/) {
+ 			splice (@ARGV, $i, 1);
+ 			--$i;
+ 		}
+ 	} elsif ($ARGV[$i] eq "-E") {
+ 		$PreprocessOnly = 1;
+ 	} elsif ($ARGV[$i] eq "-c") {
+ 		$GCCOptions .= " " . $ARGV[$i];
+ 		$CompileDontLink = 1;
+ 	} elsif ($ARGV[$i] eq "-v") {
+ 		$GCCOptions .= " " . $ARGV[$i];
+ 		$Verbose = 1;
+ 	} elsif ($ARGV[$i] eq "-o") {
+ 		$OutputFile = $ARGV[$i + 1];
+ 	} elsif ($ARGV[$i] eq "-save-temps") {
+ 		$GCCOptions .= " " . $ARGV[$i];
+ 		$SaveTemps = 1;
+ 	} elsif ($ARGV[$i] =~ /\.bc$/) {
+ 		push (@BytecodeFiles, $ARGV[$i]);
+ 	} elsif ($ARGV[$i] =~ /^-L/) {
+ 		$GCCOptions .= " " . $ARGV[$i];
+ 		push (@LibDirs, $ARGV[$i]);
+ 	} elsif ($ARGV[$i] =~ /^-l/) {
+ 		$GCCOptions .= " " . $ARGV[$i];
+ 		push (@Libs, $ARGV[$i]);
+ 	} elsif ($ARGV[$i] =~ /\.(c|cpp|cc|i|ii|C)$/) {
+ 		$LastCFile = $ARGV[$i];
+ 	}
+ }
+ 
+ sub GetDefaultOutputFileName {
+ 	my $DefaultOutputFileBase;
+ 
+ 	if ($ProgramName =~ /llvm-native-gxx/) {
+ 		$DefaultOutputFileBase = $LastCFile;
+ 	} elsif ($ProgramName =~ /native-build/) {
+ 		$DefaultOutputFileBase = $BytecodeFiles[0];
+ 	}
+ 
+ 	my $def = $DefaultOutputFileBase;
+ 
+ 	die "Can't figure out name of output file.\n"
+ 		unless $DefaultOutputFileBase
+ 			   && (($ProgramName !~ /native-build/)
+ 				   || $#BytecodeFiles == 0);
+ 
+ 	print "Warning: defaulting output file name ",
+ 		"based on '$DefaultOutputFileBase'\n" if $Verbose;
+ 
+ 	if ($ProgramName =~ /llvm-native-gxx/) {
+ 		$def =~ s/\.(c|cpp|cc|i|ii|C)$/.o/;
+ 	} elsif ($ProgramName =~ /native-build/) {
+ 		$def =~ s/\.bc$/.$Backend/;
+ 		if ($CompileDontLink) {
+ 			$def .= ".o";
+ 		}
+ 	}
+ 
+ 	return $def;
+ }
+ 
+ # run a command, optionally echoing, and quitting if it fails:
+ sub run {
+ 	my $command = join(" ", @_);
+ 	print "$command\n" if $Verbose;
+ 	$command =~ s/\"/\\\"/g;
+ 	system $command and die "$0: $command failed";
+ }
+ 
+ sub LinkBytecodeFilesIntoTemporary {
+ 	my $FinalOutputFileName = shift @_;
+ 	my @BytecodeFiles = @_;
+ 
+ 	my $BCFiles = join (" ", @BytecodeFiles);
+ 	my $LinkedBCFile;
+ 	if ($SaveTemps) {
+ 		$LinkedBCFile = "${FinalOutputFileName}.llvm.bc";
+ 	} else {
+ 		$LinkedBCFile = "/tmp/nativebuild-$$.llvm.bc";
+ 	}
+ 	run "llvm-link -o $LinkedBCFile $BCFiles";
+ 	return $LinkedBCFile;
+ }
+ 
+ sub CompileBytecodeToNative {
+ 	my ($BCFile, $Backend, $OutputFile) = @_;
+ 
+ 	my $GeneratedCode;
+ 	if ($Backend eq 'cbe') {
+ 		if ($SaveTemps) {
+ 			$GeneratedCode = "${OutputFile}.c";
+ 		} else {
+ 			$GeneratedCode = "/tmp/nativebuild-$$.c";
+ 		}
+ 		run "llc -march=c -f -o $GeneratedCode $BCFile";
+ 	} elsif ($Backend eq 'llc') {
+ 		if ($SaveTemps) {
+ 			$GeneratedCode = "${OutputFile}.s";
+ 		} else {
+ 			$GeneratedCode = "/tmp/nativebuild-$$.s";
+ 		}
+ 		run "llc -f -o $GeneratedCode $BCFile";
+ 	}
+ 	my $LibDirs = join (" ", @LibDirs);
+ 	my $Libs = join (" ", @Libs);
+ 	run "gcc $GCCOptions $GeneratedCode -o $OutputFile $LibDirs $Libs";
+ 	run "rm $BCFile $GeneratedCode"
+ 		unless $SaveTemps;
+ }
+ 
+ sub CompileCToNative {
+ 	my ($LLVMGCCCommand, $Backend, $OutputFile) = @_;
+ 	run $LLVMGCCCommand;
+ 	if ($PreprocessOnly) {
+ 		return;
+ 	}
+ 	my $BCFile = "${OutputFile}.llvm.bc";
+ 	if ($CompileDontLink) {
+ 		run "mv ${OutputFile} $BCFile";
+ 	} else { # gccld messes with the output file name
+ 		run "mv ${OutputFile}.bc $BCFile";
+ 	}
+ 	my $GeneratedCode;
+ 	if ($Backend eq 'cbe') {
+ 		$GeneratedCode = "${OutputFile}.cbe.c";
+ 		run "llc -march=c -f -o $GeneratedCode $BCFile";
+ 	} elsif ($Backend eq 'llc') {
+ 		$GeneratedCode = "${OutputFile}.llc.s";
+ 		run "llc -f -o $GeneratedCode $BCFile";
+ 	}
+ 	my $NativeGCCOptions = "";
+ 	if ($CompileDontLink) {
+ 		$NativeGCCOptions = "-c";
+ 	}
+ 	run "gcc $NativeGCCOptions $GeneratedCode -o $OutputFile";
+ 	run "rm ${OutputFile}.llvm.bc $GeneratedCode"
+ 		unless $SaveTemps;
+ }
+ 
+ # guess the name of the output file, if -o was not specified.
+ $OutputFile = GetDefaultOutputFileName () unless $OutputFile;
+ print "Output file is $OutputFile\n" if $Verbose;
+ # do all the dirty work:
+ if ($ProgramName eq /native-build/) {
+ 	my $LinkedBCFile = LinkBytecodeFilesIntoTemporary (@BytecodeFiles);
+ 	CompileBytecodeToNative ($LinkedBCFile, $Backend, $OutputFile);
+ } elsif ($ProgramName =~ /llvm-native-gxx/) {
+ 	# build the llvm-gxx command line.
+ 	$LLVMGCCCommand = join (" ", ("llvm-g++", @ARGV));
+ 	CompileCToNative ($LLVMGCCCommand, $Backend, $OutputFile);
+ }
+ 
+ # we're done.
+ exit 0;
+ 
+ __END__
+ 
+ =pod
+ 
+ =head1 NAME
+ 
+ llvm-native-gxx
+ 
+ =head1 SYNOPSIS
+ 
+ llvm-native-g++ [OPTIONS...] FILE
+ 
+ native-build [OPTIONS...] FILE
+ 
+ =head1 DESCRIPTION
+ 
+ llvm-native-g++ is a wrapper around the LLVM command-line tools which generates
+ a native object (.o) file by compiling FILE with llvm-g++, and then running 
+ an LLVM back-end (CBE by default) over the resulting bytecode, and then
+ compiling the resulting code to a native object file.
+ 
+ If called as "native-build", it compiles bytecode to native code, and takes
+ different options.
+ 
+ =head1 OPTIONS
+ 
+ llvm-native-g++ takes the same options as llvm-gcc. All options
+ except -mllvm-backend=... are passed on to llvm-g++.
+ 
+ =over 4
+ 
+ =item -mllvm-backend=BACKEND
+ 
+ Use BACKEND for native code generation. 
+ 
+ =item -v
+ 
+ Print command lines that llvm-native-g++ runs.
+ 
+ =item -o FILE
+ 
+ llvm-native-g++ tries to guess the name of the llvm-g++ output file by looking
+ for this option in the command line. If it can't find it, it finds the last C
+ or C++ source file named on the command line, and turns its suffix into .o. See
+ BUGS.
+ 
+ =item -save-temps
+ 
+ Save temporary files used by llvm-native-g++ (and llvm-g++, and g++).
+ 
+ =back
+ 
+ =head1 BUGS
+ 
+ llvm-native-g++ only handles the case where llvm-g++ compiles a single
+ file per invocation.  llvm-native-g++ has weak command-line argument
+ parsing and is a poor substitute for making g++/g++.c do this stuff.
+ 
+ This manual page does not adequately document native-build mode.
+ 
+ llvm-native-g++ is pretty gross because it represents the blind merging of two
+ other scripts that predated it. It could use some code clean-up.
+ 
+ =head1 SEE ALSO
+ 
+ g++(1)
+ 
+ =head1 AUTHOR
+ 
+ Brian R. Gaeke
+ 
+ =cut


Index: llvm/utils/NightlyTest.gnuplot
diff -u llvm/utils/NightlyTest.gnuplot:1.8 llvm/utils/NightlyTest.gnuplot:1.8.2.1
--- llvm/utils/NightlyTest.gnuplot:1.8	Wed Jan  7 12:33:14 2004
+++ llvm/utils/NightlyTest.gnuplot	Mon Mar  1 17:59:25 2004
@@ -15,6 +15,7 @@
 set label "'dummy'\nfunction" at "2003-07-20:", 150000
 set label "Reoptimizer\n removal" at "2003-08-10:", 132000
 set label "llvm-db\ncheckin" at "2004-01-04:", 145000
+set label "llvm/projects" at "2004-01-04:", 151000
 
 set size .75,.75
 plot "running_loc.txt" using 1:2 title '' with lines, \


Index: llvm/utils/check-each-file
diff -u llvm/utils/check-each-file:1.1 llvm/utils/check-each-file:1.1.2.1
--- llvm/utils/check-each-file:1.1	Thu Jan 15 16:35:43 2004
+++ llvm/utils/check-each-file	Mon Mar  1 17:59:25 2004
@@ -10,7 +10,7 @@
 	linker=./link-$program
 	echo "Building $program with llvm-native-gcc"
 	rm -f $program
-	gmake -s $program CC=llvm-native-gcc
+	gmake -e $program CC=llvm-native-gcc CXX=llvm-native-gxx
 	echo "Erasing $program and re-linking it" 
 	rm -f $program
 	echo "rm -f $program" > $linker
@@ -55,7 +55,7 @@
 	echo ""
 	echo "OBJECTS-FILE is a text file containing the names of all the .o files"
 	echo "PROGRAM is the name of the executable under test"
-	echo "(there must also exist a Makefile in the current directory which
+	echo "(there must also exist a Makefile in the current directory which"
 	echo "has PROGRAM as a target)"
 	echo "LINKER is the script that builds PROGRAM; try --make-linker-script" 
 	echo "to automatically generate it"
@@ -113,8 +113,11 @@
 echo "Recompiling everything with llvm-native-gcc"
 for f in $files
 do
-	rm -f $f && gmake $f CC=llvm-native-gcc
+	rm -f $f
+	gmake $f CC=llvm-native-gcc CXX=llvm-native-gxx
 done
+rm -f $program
+$linker
 if $checker
 then
 	echo "Sorry, I can't help you, $program is OK when compiled with llvm-native-gcc"


Index: llvm/utils/getsrcs.sh
diff -u llvm/utils/getsrcs.sh:1.12 llvm/utils/getsrcs.sh:1.12.6.1
--- llvm/utils/getsrcs.sh:1.12	Thu Oct  9 11:10:15 2003
+++ llvm/utils/getsrcs.sh	Mon Mar  1 17:59:25 2004
@@ -1,10 +1,10 @@
 #!/bin/sh
 # This is useful because it prints out all of the source files.  Useful for
 # greps.
-find docs include lib tools utils -name \*.\[cdhyl\]\* | grep -v Lexer.cpp | \
+find docs include lib tools utils projects -name \*.\[cdhyl\]\* | grep -v Lexer.cpp | \
        grep -v llvmAsmParser.cpp | grep -v llvmAsmParser.h | grep -v '~$' | \
        grep -v '\.ll$' | grep -v .flc | grep -v Sparc.burm.c | grep -v '\.d$' |\
        grep -v '\.dir$' | grep -v www/docs/doxygen | grep -v include/boost | \
-       grep -v /Burg/ | grep -v '\.lo' | grep -v '\.inc$' | \
+       grep -v /Burg/ | grep -v '\.lo' | grep -v '\.inc$' | grep -v '\.libs' | \
        grep -v TableGen/FileParser.cpp | grep -v TableGen/FileParser.h
 


Index: llvm/utils/llvm-native-gcc
diff -u llvm/utils/llvm-native-gcc:1.1 llvm/utils/llvm-native-gcc:1.1.4.1
--- llvm/utils/llvm-native-gcc:1.1	Tue Dec  9 16:23:24 2003
+++ llvm/utils/llvm-native-gcc	Mon Mar  1 17:59:25 2004
@@ -114,7 +114,7 @@
 		} else {
 			$GeneratedCode = "/tmp/nativebuild-$$.c";
 		}
-		run "llvm-dis -c -f -o $GeneratedCode $BCFile";
+		run "llc -march=c -f -o $GeneratedCode $BCFile";
 	} elsif ($Backend eq 'llc') {
 		if ($SaveTemps) {
 			$GeneratedCode = "${OutputFile}.s";
@@ -145,7 +145,7 @@
 	my $GeneratedCode;
 	if ($Backend eq 'cbe') {
 		$GeneratedCode = "${OutputFile}.cbe.c";
-		run "llvm-dis -c -f -o $GeneratedCode $BCFile";
+		run "llc -march=c -f -o $GeneratedCode $BCFile";
 	} elsif ($Backend eq 'llc') {
 		$GeneratedCode = "${OutputFile}.llc.s";
 		run "llc -f -o $GeneratedCode $BCFile";


Index: llvm/utils/profile.pl
diff -u llvm/utils/profile.pl:1.4 llvm/utils/profile.pl:1.4.4.1
--- llvm/utils/profile.pl:1.4	Sat Nov  1 23:17:32 2003
+++ llvm/utils/profile.pl	Mon Mar  1 17:59:25 2004
@@ -8,14 +8,19 @@
 # Syntax:   profile.pl [OPTIONS] bytecodefile <arguments>
 #
 # OPTIONS may include one or more of the following:
-#     -block - Enable basic block level profiling
+#     -block    - Enable basicblock-level profiling
+#     -function - Enable function-level profiling
+#     -o <filename> - Emit profiling information to the specified file, instead
+#                     of llvmprof.out
 #
 # Any unrecognized options are passed into the invocation of llvm-prof
 #
 
-my $ProfilePass = "-insert-function-profiling";
+my $ProfilePass = "-insert-block-profiling";
 
 my $LLVMProfOpts = "";
+my $ProgramOpts = "";
+my $ProfileFile = "";
 
 # Parse arguments...
 while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
@@ -24,12 +29,22 @@
 
   # List command line options here...
   if (/^-?-block$/) { $ProfilePass = "-insert-block-profiling"; next; }
+  if (/^-?-function$/) { $ProfilePass = "-insert-function-profiling"; next; }
+  if (/^-?-o$/) {         # Read -o filename...
+    die "-o option requires a filename argument!" if (!scalar(@ARGV));
+    $ProgramOpts .= " -llvmprof-output $ARGV[0]";
+    $ProfileFile = $ARGV[0];
+    shift;
+    next;
+  }
   if (/^-?-help$/) {
     print "OVERVIEW: profile.pl - Instrumentation and profile printer.\n\n";
     print "USAGE: profile.pl [options] program.bc <program args>\n\n";
     print "OPTIONS:\n";
-    print "  -block - Enable basic block level profiling\n";
-    print "  -help  - Print this usage information\n";
+    print "  -block    - Enable basicblock-level profiling\n";
+    print "  -function - Enable function-level profiling\n";
+    print "  -o <file> - Specify an output file other than llvm-prof.out.\n";
+    print "  -help     - Print this usage information\n";
     print "\nAll other options are passed into llvm-prof.\n";
     exit 1;
   }
@@ -51,6 +66,6 @@
 my $LibProfPath = $LLIPath . "/../../lib/Debug/libprofile_rt.so";
 
 system "opt -q $ProfilePass < $BytecodeFile | lli -fake-argv0 '$BytecodeFile'" .
-       " -load $LibProfPath - " . (join ' ', @ARGV);
+       " -load $LibProfPath -$ProgramOpts " . (join ' ', @ARGV);
 
-system "llvm-prof $LLVMProfOpts $BytecodeFile";
+system "llvm-prof $LLVMProfOpts $BytecodeFile $ProfileFile";





More information about the llvm-commits mailing list