Make .bc en/decoding of AttrKind stable
authorTobias Grosser <tobias@grosser.es>
Fri, 26 Jul 2013 04:16:55 +0000 (04:16 +0000)
committerTobias Grosser <tobias@grosser.es>
Fri, 26 Jul 2013 04:16:55 +0000 (04:16 +0000)
commite7bc5bb8622123b4a1507e7d219ab570a43e5bdf
tree31bf0371d5d0601560856c0f43498648c72456cf
parentb3053c528a570d20a4562e00dbecd1947f4848e7
Make .bc en/decoding of AttrKind stable

The bitcode representation attribute kinds are encoded into / decoded from
should be independent of the current set of LLVM attributes and their position
in the AttrKind enum. This patch explicitly encodes attributes to fixed bitcode
values.

With this patch applied, LLVM does not silently misread attributes written by
LLVM 3.3. We also enhance the decoding slightly such that an error message is
printed if an unknown AttrKind encoding was dected.

Bonus: Dropping bitcode attributes from AttrKind is now easy, as old AttrKinds
       do not need to be kept to support the Bitcode reader.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187186 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Bitcode/LLVMBitCodes.h
lib/Bitcode/Reader/BitcodeReader.cpp
lib/Bitcode/Reader/BitcodeReader.h
lib/Bitcode/Writer/BitcodeWriter.cpp
test/Bitcode/attributes-3.3.ll [new file with mode: 0644]
test/Bitcode/attributes-3.3.ll.bc [new file with mode: 0644]