[llvm-commits] [llvm] r169040 - /llvm/trunk/tools/llc/llc.cpp
Jakob Stoklund Olesen
stoklund at 2pi.dk
Fri Nov 30 13:42:47 PST 2012
Author: stoklund
Date: Fri Nov 30 15:42:47 2012
New Revision: 169040
URL: http://llvm.org/viewvc/llvm-project?rev=169040&view=rev
Log:
Add a -time-compilations=<N> option to llc.
This causes llc to repeat the module compilation N times, making it
possible to get more accurate information from -time-passes when
compiling small modules.
Modified:
llvm/trunk/tools/llc/llc.cpp
Modified: llvm/trunk/tools/llc/llc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llc/llc.cpp?rev=169040&r1=169039&r2=169040&view=diff
==============================================================================
--- llvm/trunk/tools/llc/llc.cpp (original)
+++ llvm/trunk/tools/llc/llc.cpp Fri Nov 30 15:42:47 2012
@@ -51,6 +51,11 @@
static cl::opt<std::string>
OutputFilename("o", cl::desc("Output filename"), cl::value_desc("filename"));
+static cl::opt<unsigned>
+TimeCompilations("time-compilations", cl::Hidden, cl::init(1u),
+ cl::value_desc("N"),
+ cl::desc("Repeat compilation N times for timing"));
+
// Determine optimization level.
static cl::opt<char>
OptLevel("O",
@@ -71,6 +76,8 @@
cl::desc("Disable simplify-libcalls"),
cl::init(false));
+static int compileModule(char**, LLVMContext&);
+
// GetFileNameRoot - Helper function to get the basename of a filename.
static inline std::string
GetFileNameRoot(const std::string &InputFilename) {
@@ -181,6 +188,15 @@
cl::ParseCommandLineOptions(argc, argv, "llvm system compiler\n");
+ // Compile the module TimeCompilations times to give better compile time
+ // metrics.
+ for (unsigned I = TimeCompilations; I; --I)
+ if (int RetVal = compileModule(argv, Context))
+ return RetVal;
+ return 0;
+}
+
+static int compileModule(char **argv, LLVMContext &Context) {
// Load the module to be compiled...
SMDiagnostic Err;
std::auto_ptr<Module> M;
More information about the llvm-commits
mailing list