diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2012-11-30 21:42:47 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2012-11-30 21:42:47 +0000 |
commit | 882092808b7179e49ee5c52c07ce9c97e3128a81 (patch) | |
tree | 0e24cd3af27b3a684b31deca92cffd8fdc60ea82 | |
parent | 8244121b9c130ff2529f3e3ebb3ef2fa4646ba34 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169040 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | tools/llc/llc.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp index 4d4a74c009..41ec815719 100644 --- a/tools/llc/llc.cpp +++ b/tools/llc/llc.cpp @@ -51,6 +51,11 @@ InputFilename(cl::Positional, cl::desc("<input bitcode>"), cl::init("-")); 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 @@ 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<Module> M; |