<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Jul 13, 2015 at 5:44 PM, Adrian Prantl <span dir="ltr"><<a href="mailto:aprantl@apple.com" target="_blank">aprantl@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
> On Jul 13, 2015, at 1:48 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:<br>
><br>
> On Mon, Jul 13, 2015 at 9:37 AM, Adrian Prantl <<a href="mailto:aprantl@apple.com">aprantl@apple.com</a>> wrote:<br>
> I actually removed the initialization from ObjectFilePCHContainerOperations in r241653. Is this still reproducing for you?<br>
><br>
> Yes. To reproduce, delete your module cache and build anything that will trigger an implicit module build with -ftime-report.<br>
<br>
</span>I could reproduce this now!<br>
<br>
Since we’re explicitly initializing CodeGenOpts, the other options are safe from being parsed twice.<br>
However, -time-passes is special:<br>
<br>
In BackendUtil, we are doing this:<br>
<br>
>   if (llvm::TimePassesIsEnabled)<br>
>     BackendArgs.push_back("-time-passes”);<br>
>   BackendArgs.push_back(nullptr);<br>
>   llvm::cl::ParseCommandLineOptions(BackendArgs.size() - 1,<br>
>                                     BackendArgs.data());<br>
<br>
but looking at the definition of the -time-passes options, it looks to me as if this is actually a noop because all it would do is set the flag that was already set. (TimePassesIsEnabled is being initialized in CodeGenAction).<br>
<br>
> /===----------------------------------------------------------------------===//<br>
> // TimingInfo implementation<br>
><br>
> bool llvm::TimePassesIsEnabled = false;<br>
> static cl::opt<bool,true><br>
> EnableTiming("time-passes", cl::location(TimePassesIsEnabled),<br>
>             cl::desc("Time each pass, printing elapsed time for each on exit"));<br>
<br>
So my suggestion is to just remove the handling of TimePassesIsEnabled from BackendUtil. I’m quite unfamiliar with the command line handling so I may be missing something. Do you agree with either of the last two sentences?<br></blockquote><div><br></div><div>Yes, I'd dug into this and reached the same conclusion myself. I'm not sure whether LLVM expects us to be poking at its global directly, but it doesn't make sense to both do that *and* specify the flag.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I also looked into reorganizing BackendUtil to cache the TargetMachine instead, but this turned out to be much more difficult than expected because clang modules actually want different codegen options than the main compilation unit, so I’d like to avoid this for now.<br>
<span class="HOEnZb"><font color="#888888"><br>
-- adrian</font></span></blockquote></div><br></div></div>