[LLVMdev] [!] Breaking changes to GC infrastructure

Gordon Henriksen gordonhenriksen at me.com
Sun Aug 17 11:47:30 PDT 2008


Hi all,

In order to support linking AsmWriter separately from CodeGen, the  
Collector class (a CodeGen component) had to be decoupled from the  
AsmWriter interface. This required moving the beginAssembly and  
endAssembly methods to a separate abstract base class. If you had  
overridden these methods, your class may compile successfully but fail  
at runtime with a message of the form:

     no GCMetadataPrinter registered for collector: %s

The fix is to transition your overrides to a subclass of  
GCMetadataPrinter:

  1. Subclass GCMetadataPrinter and move your beginAssembly and  
endAssembly implementations there. The GCMetadataPrinter has the same  
data accessors as Collector (now GCStrategy), so your implementation  
shouldn't need many changes.

       class BespokeGCPrinter : public GCMetadataPrinter {
       public:
         void beginAssembly(...) { ... }
         void endAssembly(...) { ... }
       };

  2. Register your printer with GCMetadataPrinterRegistry.

       GCMetadataPrinterRegistry::Add<BespokeGCPrinter>
       X("bespoke", "my bespoke");

  3. Set the new UsesMetadata flag in your Collector subclass'  
constructor so that the AsmWriter will look for your assembly printer:

       MyGC::MyGC() {
         ...
         UsesMetadata = true;
       }


In addition, I took the breaking change as an opportunity to rename  
some classes so that their role will hopefully be clearer. In  
particular, Collector was confusing to implementors. Several thought  
that this compile-time class was the place to implement their runtime  
GC heap. Of course, it doesn't even exist at runtime.

Specifically, the renames are:

   Collector               -> GCStrategy
   CollectorMetadata       -> GCFunctionInfo
   CollectorModuleMetadata -> GCModuleInfo
   CollectorRegistry       -> GCRegistry
   Function::getCollector  -> getGC [setGC, hasGC, clearGC]

Several accessors and nested types have also been renamed to be  
consistent. These changes should be obvious.


Please let me know if you have any questions!

Thanks,
Gordon


P.S. Sorry for the short notice; this just came up yesterday.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080817/c98bcfa0/attachment.html>


More information about the llvm-dev mailing list