Changing TableGen getAllDerivedDefinitions to return `ArrayRef<const Record *>`?

Revisiting this, I came up with a less intrusive scheme to introduce this change gradually in this PR: [TableGen] Add const variants of accessors for backend by jurahul · Pull Request #106658 · llvm/llvm-project (github.com)

The main change is to have const and non-const overloads of these functions which return different types:

  • const versions of these accessors return vectors of const Record* (a reference if the accessor is backed by a cache, else by value).
  • Non-const version return vectors of just Record * (again, a reference if backed by a cache, else by value).

Most current backends will only work with the non-const versions which retain the old interface, so the change also changes all RecordKeeper references in existing backends to non-const. A few that are already using const RecordKeeper& either just continue to work or have minor fixes.

One caveat is that there are now two Cache objects in the RecordKeeper class, one to server the const variants and other for non-const. For a given backend, only one of them should ever be non-empty, so this is just temporary cruft till we transition all backend to have proper const correctness w.r.t the records.

Thanks
Rahul