[llvm] [TableGen] Allow empty terminator in SequenceToOffsetTable (PR #119751)
Rahul Joshi via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 12 12:38:04 PST 2024
================
@@ -97,25 +103,27 @@ class SequenceToOffsetTable {
bool empty() const { return Seqs.empty(); }
unsigned size() const {
- assert((empty() || Entries) && "Call layout() before size()");
+ assert(IsLaidOut && "Call layout() before size()");
return Entries;
}
/// layout - Computes the final table layout.
void layout() {
- assert(Entries == 0 && "Can only call layout() once");
+ assert(!IsLaidOut && "Can only call layout() once");
+ IsLaidOut = true;
+
// Lay out the table in Seqs iteration order.
for (typename SeqMap::iterator I = Seqs.begin(), E = Seqs.end(); I != E;
++I) {
I->second = Entries;
// Include space for a terminator.
- Entries += I->first.size() + 1;
+ Entries += I->first.size() + Terminator.has_value();
----------------
jurahul wrote:
nit: Can we just do:
```
if (Terminator.has_value())
Entries += Seqs.size();
```
after the loop?
https://github.com/llvm/llvm-project/pull/119751
More information about the llvm-commits
mailing list