[PATCH] D108438: Improve the dumpability of bitstream/bitcode headers
William Woodruff via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 19 19:20:37 PDT 2021
woodruffw created this revision.
woodruffw added a reviewer: pcc.
woodruffw added a project: LLVM.
woodruffw requested review of this revision.
Herald added a subscriber: llvm-commits.
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!
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D108438
Files:
llvm/include/llvm/Bitcode/LLVMBitCodes.h
llvm/include/llvm/Bitstream/BitCodeEnums.h
llvm/include/llvm/Bitstream/BitCodes.h
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108438.367687.patch
Type: text/x-patch
Size: 7518 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210820/30ab0bef/attachment.bin>
More information about the llvm-commits
mailing list