[PATCH] Make .bc en/decoding of AttrKind stable

Nick Lewycky nlewycky at google.com
Thu Jul 25 17:29:03 PDT 2013


On 17 July 2013 15:54, Tobias Grosser <tobias at grosser.es> wrote:

> Hi,
>
> I would like to commit the following patch:
>
> ----------------------
> 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.
> ----------------------
>
> I also considered assigning fixed numbers directly in the AttrKind enum
> (or keeping the enum stable), but convinced myself that the bitcode
> encoding should really not part of the IR interface.
>
> OK to commit?
>

Thanks for working on this.

+  default:
+    return Error("Unknown attribute kind");

Any chance we could get the value of the attribute kind in there? I know, I
know, but I forsee a future Nick debugging exactly this.

+; RUN:  llvm-dis < %s.bc| FileCheck %s

Space before pipe please. :)

LGTM. Thanks so much for the test, too!

Nick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130725/83d297d7/attachment.html>


More information about the llvm-commits mailing list