From: Jakob Stoklund Olesen Date: Fri, 30 Nov 2012 21:42:47 +0000 (+0000) Subject: Add a -time-compilations= option to llc. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2776b4c624db4b79b8b7d8eb4f5a55ab6e6dab92;p=platform%2Fupstream%2Fllvm.git Add a -time-compilations= 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. llvm-svn: 169040 --- diff --git a/llvm/tools/llc/llc.cpp b/llvm/tools/llc/llc.cpp index 4d4a74c..41ec815 100644 --- a/llvm/tools/llc/llc.cpp +++ b/llvm/tools/llc/llc.cpp @@ -51,6 +51,11 @@ InputFilename(cl::Positional, cl::desc(""), cl::init("-")); static cl::opt OutputFilename("o", cl::desc("Output filename"), cl::value_desc("filename")); +static cl::opt +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 OptLevel("O", @@ -71,6 +76,8 @@ DisableSimplifyLibCalls("disable-simplify-libcalls", 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 @@ int main(int argc, char **argv) { 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 M;