This is an archive of the discontinued LLVM Phabricator instance.

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

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

Details

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!

csigg added a comment.Nov 8 2021, 10:05 AM

Hi River, did you plan to merge this? I was going to remove the dlopen cruft in the kythe indexer if you do. Thanks!

Hi River, did you plan to merge this? I was going to remove the dlopen cruft in the kythe indexer if you do. Thanks!

Oops, thought I did. I must have gotten side tracked, I'll land shortly.