Page MenuHomePhabricator

[Tablegen] Collect all global state into one managed static
AcceptedPublic

Authored by rriddle on Aug 30 2021, 12:06 PM.

Details

Reviewers
csigg
lattner
Summary

Tablegen uses copious amounts of global state for uniquing various records.
This was fine under the original vision where tablegen was a tool, and not a
library, but there are various usages of tablegen that want to use it as a library.
One concrete example is that downstream we have a kythe indexer for tablegen
constructs that allows for IDEs to serve go-to-definition/references/and more.
We currently (kind of hackily) keep the tablegen parts in a shared library that
gets loaded/unloaded.

This revision starts to remedy this by globbing all of the static state into a
managed static so that they can at least be unloaded with llvm_shutdown.
A better solution would be to feed in a context variable (much like how
the IR in LLVM/MLIR do), but that is a more invasive change that can come later.

Diff Detail

Event Timeline

rriddle created this revision.Aug 30 2021, 12:06 PM
rriddle requested review of this revision.Aug 30 2021, 12:06 PM
lattner accepted this revision.Aug 30 2021, 9:19 PM

Ok. tblgen needs a complete rewrite IMO. :-)

This seems like a fine lateral step that solves some problems, I'm cool with that.

This revision is now accepted and ready to land.Aug 30 2021, 9:19 PM
csigg accepted this revision.Sep 9 2021, 11:30 AM

This is wonderful, thank you very much for doing this!