[PATCH] D41695: [Metadata] Extend 'count' field of DISubrange to take a metadata node

Sander de Smalen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 18 09:57:24 PST 2018


sdesmalen added inline comments.


================
Comment at: include/llvm/IR/DebugInfoMetadata.h:372
+
+  ConstantInt *getCount() const {
+    if (auto *MD = dyn_cast<ConstantAsMetadata>(getRawCountNode()))
----------------
aprantl wrote:
> Perhaps:
> `Optional<ConstantInt *> getConstantCount()` ?
I changed it into getConstantCountOrNull() and getCountVariableOrNull().


================
Comment at: lib/Bitcode/Writer/BitcodeWriter.cpp:1445
   Record.push_back(N->isDistinct());
-  Record.push_back(N->getCount());
+  Record.push_back(-1); // this field has become obsolete
+  Record.push_back(VE.getMetadataOrNullID(N->getRawCountNode()));
----------------
aprantl wrote:
> We typically version bitcode by adding a bit to the flags, like this:
> ` Record.push_back(N->isDistinct() | 1<<1);`
> This way we don't have to waste the space for the obsoleted field.
Good suggestion, thanks! I updated the patch with the versioning and added a test-case for it as well. Let me know if you think the test-case covers it well enough.


https://reviews.llvm.org/D41695





More information about the llvm-commits mailing list