<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Wed, Jan 17, 2018 at 10:12 AM Adrian Prantl via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">aprantl added a comment.<br>
<br>
It looks like this changes the layout of DISubrange from<br>
<br>
Flags | Count |<br>
<br>
<br>
<br>
================<br>
Comment at: include/llvm/IR/DebugInfoMetadata.h:372<br>
+<br>
+  ConstantInt *getCount() const {<br>
+    if (auto *MD = dyn_cast<ConstantAsMetadata>(getRawCountNode()))<br>
----------------<br>
Perhaps:<br>
`Optional<ConstantInt *> getConstantCount()` ?<br></blockquote><div><br>FWIW (& opinions vary, this isn't something that's clearly one way or the other I think) - I generally use an existing empty state if there is one, like nullptr. Adding an extra empty state seems likely to be confusing - if I see Optional<T*> then I assume there's None, null, and the non-null values - and have to think about what the difference might be between None and null.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
================<br>
Comment at: lib/Bitcode/Writer/BitcodeWriter.cpp:1445<br>
   Record.push_back(N->isDistinct());<br>
-  Record.push_back(N->getCount());<br>
+  Record.push_back(-1); // this field has become obsolete<br>
+  Record.push_back(VE.getMetadataOrNullID(N->getRawCountNode()));<br>
----------------<br>
We typically version bitcode by adding a bit to the flags, like this:<br>
` Record.push_back(N->isDistinct() | 1<<1);`<br>
This way we don't have to waste the space for the obsoleted field.<br>
<br>
<br>
<a href="https://reviews.llvm.org/D41695" rel="noreferrer" target="_blank">https://reviews.llvm.org/D41695</a><br>
<br>
<br>
<br>
</blockquote></div></div>