[all-commits] [llvm/llvm-project] 0d6ca2: [TableGen][DecoderEmitter] Fix decoder reading byt...

Sergei Barannikov via All-commits all-commits at lists.llvm.org
Fri Aug 22 14:52:09 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0d6ca2f969332c76f78105f88b373d5aa1810922
      https://github.com/llvm/llvm-project/commit/0d6ca2f969332c76f78105f88b373d5aa1810922
  Author: Sergei Barannikov <barannikov88 at gmail.com>
  Date:   2025-08-23 (Sat, 23 Aug 2025)

  Changed paths:
    A llvm/test/TableGen/FixedLenDecoderEmitter/var-len-conflict-1.td
    A llvm/test/TableGen/FixedLenDecoderEmitter/var-len-conflict-2.td
    M llvm/utils/TableGen/DecoderEmitter.cpp

  Log Message:
  -----------
  [TableGen][DecoderEmitter] Fix decoder reading bytes past instruction (#154916)

See the added test. Before this change the decoder would first read
the second byte, despite the fact that there are 1-byte instructions
that could match:

```
/* 0 */       MCD::OPC_ExtractField, 8, 8,  // Inst{15-8} ...
/* 3 */       MCD::OPC_FilterValue, 0, 4, 0, // Skip to: 11
/* 7 */       MCD::OPC_Decode, 186, 2, 0, // Opcode: I16_0, DecodeIdx: 0
/* 11 */      MCD::OPC_FilterValue, 1, 4, 0, // Skip to: 19
/* 15 */      MCD::OPC_Decode, 187, 2, 0, // Opcode: I16_1, DecodeIdx: 0
/* 19 */      MCD::OPC_FilterValue, 2, 4, 0, // Skip to: 27
/* 23 */      MCD::OPC_Decode, 188, 2, 0, // Opcode: I16_2, DecodeIdx: 0
/* 27 */      MCD::OPC_ExtractField, 0, 1,  // Inst{0} ...
/* 30 */      MCD::OPC_FilterValue, 0, 4, 0, // Skip to: 38
/* 34 */      MCD::OPC_Decode, 189, 2, 1, // Opcode: I8_0, DecodeIdx: 1
/* 38 */      MCD::OPC_FilterValueOrFail, 1,
/* 40 */      MCD::OPC_Decode, 190, 2, 1, // Opcode: I8_1, DecodeIdx: 1
/* 44 */      MCD::OPC_Fail,
```

There are no changes in the generated files. The only in-tree target
that uses variable length decoder is M68k, which is free of decoding
conflicts that could result in the decoder doing OOB access.

This also fixes misaligned "Decoding Conflict" dump,
prettified example output is shown in the second test.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list