<div dir="ltr">Hi,<div><br></div><div>As part of PR27551 I want to add a string table to the bitcode format to allow global value and comdat names to be shared with the proposed symbol table (and, as side effects, allow comdat names to be shared with value names, make bitcode files more compressible and make bitcode easier to parse). The format of the string table would be a top-level block containing a blob containing null-terminated strings [0] similar to the string table format used in most object files. </div><div><br></div><div>The format of MODULE_CODE_{FUNCTION,GLOBALVAR,ALIAS,IFUNC,COMDAT} records would change so that their first operand would specify their names with a byte offset into the string table. (To allow for backwards compatibility, I would increment the bitcode version.) Here is what it would look like as bcanalyzer output:</div><div><br></div><div><MODULE_BLOCK></div><div> <VERSION op0=2></div><div> <COMDAT op0=0 ...> ; name = foo</div><div> <FUNCTION op0=0 ...> ; name = foo</div><div> <GLOBALVAR op0=4 ...> ; name = bar</div><div> <ALIAS op0=8 ...> ; name = baz</div><div> ; function bodies, etc.<br></div><div></MODULE_BLOCK></div><div><STRTAB_BLOCK></div><div> <STRTAB_BLOB blob="foo\0bar\0baz\0"></div><div></STRTAB_BLOCK></div><div><br></div><div>Each STRTAB_BLOCK would apply to all preceding MODULE_BLOCKs. This means that bitcode files can continue to be concatenated with "llvm-cat -b". (Normally bitcode files would contain a single string table, which in multi-module bitcode files would be shared between modules.)</div><div><br></div><div>This *almost* allows us to remove the global (top-level) VST entirely, if not for the function offset in the FNENTRY record. However, this offset is not actually required because we can scan the module's FUNCTION_BLOCK_IDs as we were doing before <a href="http://reviews.llvm.org/D12536">http://reviews.llvm.org/D12536</a> (this may have a performance impact, so I'll measure it first).</div><div><br></div><div>Assuming that performance looks good, does this seem reasonable to folks?</div><div><br></div><div>Thanks,</div><div>-- <br><div class="gmail_signature"><div dir="ltr">-- <div>Peter</div><div><br></div><div>[0] This means that no GlobalValue or comdat name can contain a null, but this isn't substantially more restrictive than what we already have. The restriction already exists in the form of an assert for value names containing nulls (but not comdats) and we reject value and comdat names containing nulls in the textual IR parser. The COFF/ELF/MachO object formats do not support nulls in symbol or comdat names. The wasm format could in principle support nulls in symbol names, but as mentioned we already reject nulls early for IR symbols and wasm does not support comdats (yet). The missing restriction on comdat names seems to be just a bug, so we could assert on comdat names containing nulls as well.</div></div></div>
</div></div>