[PM] Implement the final conclusion as to how the analysis IDs should
work in the face of the limitations of DLLs and templated static
variables.

This requires passes that use the AnalysisBase mixin provide a static
variable themselves. So as to keep their APIs clean, I've made these
private and befriended the CRTP base class (which is the common
practice).

I've added documentation to AnalysisBase for why this is necessary and
at what point we can go back to the much simpler system.

This is clearly a better pattern than the extern template as it caught
*numerous* places where the template magic hadn't been applied and
things were "just working" but would eventually have broken
mysteriously.

llvm-svn: 263216
diff --git a/llvm/unittests/IR/PassManagerTest.cpp b/llvm/unittests/IR/PassManagerTest.cpp
index 857b528..c00748c 100644
--- a/llvm/unittests/IR/PassManagerTest.cpp
+++ b/llvm/unittests/IR/PassManagerTest.cpp
@@ -40,9 +40,14 @@
   }
 
 private:
+  friend AnalysisBase<TestFunctionAnalysis>;
+  static char PassID;
+
   int &Runs;
 };
 
+char TestFunctionAnalysis::PassID;
+
 class TestModuleAnalysis : public AnalysisBase<TestModuleAnalysis> {
 public:
   struct Result {
@@ -61,9 +66,14 @@
   }
 
 private:
+  friend AnalysisBase<TestModuleAnalysis>;
+  static char PassID;
+
   int &Runs;
 };
 
+char TestModuleAnalysis::PassID;
+
 struct TestModulePass : PassBase<TestModulePass> {
   TestModulePass(int &RunCount) : RunCount(RunCount) {}