[all-commits] [llvm/llvm-project] d81b01: [NFC][Bitstream] Improve the dumpability of bitstr...

William Woodruff via All-commits all-commits at lists.llvm.org
Tue Apr 5 15:11:06 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d81b014469a5c96c0fd5b2e441472f26cfa8a53b
      https://github.com/llvm/llvm-project/commit/d81b014469a5c96c0fd5b2e441472f26cfa8a53b
  Author: William Woodruff <william at yossarian.net>
  Date:   2022-04-05 (Tue, 05 Apr 2022)

  Changed paths:
    M llvm/include/llvm/Bitcode/LLVMBitCodes.h
    A llvm/include/llvm/Bitstream/BitCodeEnums.h
    M llvm/include/llvm/Bitstream/BitCodes.h

  Log Message:
  -----------
  [NFC][Bitstream] Improve the dumpability of bitstream/bitcode headers

The `LLVMBitCodes.h` header contains various enums that are updated whenever LLVM's bitcode fundamentally changes. It would be nice to track these changes in a semi-automated way, so that external tools that attempt to parse LLVM's bitstream and bitcode can remain in sync.

Before this change, `LLVMBitCodes.h` had a single dependency -- it needed the `FIRST_APPLICATION_BLOCKID` enum value from `BitCodes.h`. `BitCodes.h`, in turn, had a whole tree of include dependencies that boiled down to `llvm-config.h`, meaning that it was impossible to dump the AST of either file without having a partial or full LLVM build tree already present.

To eliminate that requirement, this patch introduces a new leaf-only header, `BitCodeEnums.h`, which includes the "core" enums originally in `BitCodes.h`. `LLVMBitCodes.h` and `BitCodes.h` both include this new header in turn, preserving the current header relationships while allowing `LLVMBitCodes.h` to be dumped fully independently with a command like this (run from the repository root):

```
clang -fsyntax-only -x c++ -Illvm/include -Xclang -ast-dump=json -Xclang -ast-dump-filter -Xclang llvm::bitc::BlockIDs llvm/include/llvm/Bitcode/LLVMBitCodes.h
```

I recognize that this is a pretty unusual change and perhaps not a guarantee that the LLVM authors would like to make in the general case (i.e., that individual files within LLVM can have their AST dumped with minimal dependencies). However, I believe the criticality/limited scope of the file(s) in this patch warrants an exception. Please let me know if there's any other information I can provide, or anything else I can do to improve this patch!

Reviewed By: tejohnson

Differential Revision: https://reviews.llvm.org/D108438




More information about the All-commits mailing list