aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/GCMetadataPrinter.cpp
diff options
context:
space:
mode:
authorPhilip Reames <listmail@philipreames.com>2016-01-19 18:34:27 +0000
committerPhilip Reames <listmail@philipreames.com>2016-01-19 18:34:27 +0000
commit0f6650e8e85fd280917b7534fd7eb41d209e6616 (patch)
treee86d3a55aa70f31c62a142fc3898dfe88c07b200 /llvm/lib/CodeGen/GCMetadataPrinter.cpp
parent294572f11699c4e8f5fca7f11c64540afa04c93d (diff)
downloadllvm-0f6650e8e85fd280917b7534fd7eb41d209e6616.zip
llvm-0f6650e8e85fd280917b7534fd7eb41d209e6616.tar.gz
llvm-0f6650e8e85fd280917b7534fd7eb41d209e6616.tar.bz2
[GC] Registry initialization and linkage interactions
The Registry class constructs a linked list of nodes whose storage is inside static variables and nodes are added via static initializers. The trick is that those static initializers are in both the LLVM code base, and some random plugin that might get loaded in at runtime. The existing code tries to use C++ templates and their ODR rules to get a single definition of the registry for each type, but, experimentally, this doesn't quite work as designed. (Well, the entire structure doesn't. It might not actually be an ODR problem.) Previously, when I tried moving the GCStrategy class (along with it's registry) from CodeGen to IR, I ran into a problem where asking the GCStrategyRegistry a question would return inconsistent results depending on whether you asked from CodeGen (where the static initializers still were) or Transforms. My best guess is that this is a result of either a) an order of initialization error, or b) we ended up with two copies of the registry being created. I remember at the time having convinced myself it was probably (b), but I don't have any of my notes around from that investigation any more. See http://reviews.llvm.org/rL226311 for the original patch in question. This patch tries to remove the possibility of (b) above. (a) was already fixed in change 258109. Differential Revision: http://reviews.llvm.org/D16170 llvm-svn: 258157
Diffstat (limited to 'llvm/lib/CodeGen/GCMetadataPrinter.cpp')
-rw-r--r--llvm/lib/CodeGen/GCMetadataPrinter.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/GCMetadataPrinter.cpp b/llvm/lib/CodeGen/GCMetadataPrinter.cpp
index bb8cfa1..8003219 100644
--- a/llvm/lib/CodeGen/GCMetadataPrinter.cpp
+++ b/llvm/lib/CodeGen/GCMetadataPrinter.cpp
@@ -17,3 +17,7 @@ using namespace llvm;
GCMetadataPrinter::GCMetadataPrinter() {}
GCMetadataPrinter::~GCMetadataPrinter() {}
+
+// Stamp out the registry of GCMetadataPrinter objects so that pulgins can load
+// new Strategies.
+DEFINE_REGISTRY(GCMetadataPrinter)