[cfe-dev] why does clang re-evaluate the target info for each input file?
Ted Kremenek
kremenek at apple.com
Fri Feb 29 11:19:59 PST 2008
On Feb 29, 2008, at 10:50 AM, Sam Bishop wrote:
> The subject line says it all, I suppose. It seems to me that the
> target
> would be a per-invocation constant. Is state modified that needs to
> be
> refreshed?
>
> clang.cpp:main():
> for (unsigned i = 0, e = InputFilenames.size(); i != e; ++i) {
> const std::string &InFile = InputFilenames[i];
> ...
> <if not a serialized file> {
> Target = TargetInfo::CreateTargetInfo(&triples[0],
> &triples[0]+triples.size(),
> &Diags);
> }
> ...
> }
>
> If we want to optimize for the serialized case, perhaps we could
> allocate
> the target information lazily?
Hi Sam,
Originally the Target was computed only once, prior to adding
serialization support. Because the changes I made to the driver when
I added serialization support were fairly invasive, small
inefficiencies like this were (deliberately) introduced. The desired
tradeoff at the time was to have my changes be more readable and
understandable at the cost of a few things in the driver being
slightly less efficient. The hope was that this would help shake out
bugs introduced by my changes (of which there were several that we
encountered). Certainly some of these inefficiencies can (and should)
be fixed. I am fine with introducing optimizations like the one you
suggest as long as we also aim to keep the driver readable and
maintainable.
Ted
More information about the cfe-dev
mailing list