<div dir="ltr"><div><div><div><div><div><div><div>I am trying to improve my application's compile-time performance.<br><br></div>On a given workload, I take 68 seconds to compile some code. If I disable the LLVM code generation (i.e. I will generate IR instructions, but skip the LLVM optimization and instruction selection steps) then my compile time drops to 3 seconds.  If I write out the LLVM IR (just to prove that I am generating it) then my compile time is 4 seconds. We're spending >90% of the time in LLVM code generation.<br><br></div>To try to determine if there's anything I can do, I ran:<br><br> time /tools/llvm/3.7.1dbg/bin/opt -O1 -filetype=obj -o opt.o my_ir.ll -time-passes<br><br></div>and I get:<br><br>===-------------------------------------------------------------------------===<br>                      ... Pass execution timing report ...<br>===-------------------------------------------------------------------------===<br>  Total Execution Time: 19.1382 seconds (19.1587 wall clock)<br><br>   ---User Time---   --System Time--   --User+System--   ---Wall Time---  --- Name ---<br>   4.4755 ( 23.5%)   0.0000 (  0.0%)   4.4755 ( 23.4%)   4.4806 ( 23.4%)  Dead Store Elimination<br>   3.6255 ( 19.0%)   0.0000 (  0.0%)   3.6255 ( 18.9%)   3.6282 ( 18.9%)  Combine redundant instructions<br>   1.2138 (  6.4%)   0.0040 (  5.0%)   1.2178 (  6.4%)   1.2185 (  6.4%)  SROA<br>...<br>real    1m7.783s<br>user    1m7.548s<br>sys     0m0.183s<br><br></div>So: opt reports that it took 19 seconds, but overall, the run took 88 seconds. The system in question is a 6-core AMD K10 with 8GB of memory. The system is not running anything else at the time.<br><br></div>What activity accounts for the unaccounted-for time?<br><br></div>For my application, IR verification has pathological performance (I ought to file a bug on that), therefore I disable it. It is not clear if the IR verifier is running in my opt runs. There is no line item for it.<br><br></div>It is also not clear if opt does instruction selection. I tried specifying -filetype=null but that makes no difference to the run time.<br><br></div>