Moving to cfe-dev to catch the attention of people who know something about this…
Author: atrick
Date: Tue Jun 19 22:42:09 2012
New Revision: 158787URL: http://llvm.org/viewvc/llvm-project?rev=158787&view=rev
Log:
Move the implementation of LoopInfo into LoopInfoImpl.h.The implementation only needs inclusion from LoopInfo.cpp and
MachineLoopInfo.cpp. Clients of the interface should only include the
interface. This makes the interface readable and speeds up rebuilds
after modifying the implementation.Technically speaking, I think you need to declare the templates as ‘extern’ for this to be valid (http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=549 is the best link I have).
This is a C++11 feature, but it is available with GCC since ~forever as an extension. It often “just works” without it, but my understanding is that technically it isn’t valid as any old TU that uses these constructs is supposed to have a definition available.
At least for compilers that support it putting the various things like:
extension extern template class LoopInfoBase<BasicBlock, Loop>;
Into the header would make me happier…
I’m OK relying on compilers to make this “just work” if they don’t support the extension (MSVC likely, dunno), but where the do, this will make sure everything works together nicely.
I thought the “extern template” was purely an optimization and unlikely to have any benefit with clang in this limited setting. But I’m glad you pointed it out, because I was hoping someone could explain the situation to me.
My basis for making the change to explicit instantiation is that we’ve been using the pattern for a year now elsewhere in LLVM and no one has complained. I didn’t mess with “extern template” because I didn’t want to introduce something confusing and compiler-specific without a good reason.
-Andy