llvm-project
fa70420c - [CIR] Add bytecode encodings for attributes (#229586)

Commit
13 days ago
[CIR] Add bytecode encodings for attributes (#229586) Without a BytecodeDialectInterface, MLIR encodes a dialect's attributes through their assembly format, embedding the printed text in the bytecode. This adds native encodings for 27 CIR attributes (constants, constant initializers, global views, method/data-member pointers, C++ special-member attributes, and small metadata attributes), modelled on the LLVM dialect's bytecode support. On attribute-dense modules this shrinks the bytecode ~30-40% (8.6KB to 5.4KB across the new tests). The room ahead is huge, emitting bytecode for CIRGenModule.cpp (441MB of CIR text) still exceeds 22GB RSS and 30 minutes with these encodings (64GB and 45 minutes without), since types keep using the assembly fallback. This is paving towards selfhosting with bytecode. Coverage is partial by design: anything not listed keeps using the assembly-format fallback, exactly as before. Types keep the fallback too until the type encodings land separately. Tests in the new clang/test/CIR/Bytecode directory round-trip each encoding through -verify-roundtrip and check the emitted bytecode (via llvm-strings) contains none of the attributes' printed forms.
Author
Parents
Loading