[PATCH] D116480: [DebugInfo] Avoid triggering global location assert for 2-byte pointer sizes.

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 4 10:41:41 PST 2022


dblaikie added inline comments.


================
Comment at: llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:263-308
+      // 16-bit platforms like MSP430 and AVR take this path, so sink this
+      // assert to platforms that use it.
+      auto GetPointerSize = [this]() {
+        unsigned PointerSize = Asm->getDataLayout().getPointerSize();
+        assert((PointerSize == 4 || PointerSize == 8) &&
+               "Add support for other sizes if necessary");
+        return PointerSize;
----------------
Maybe like this? (open to better naming)


================
Comment at: llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:265-270
+      auto GetPointerSize = [this]() {
+        unsigned PointerSize = Asm->getDataLayout().getPointerSize();
+        assert((PointerSize == 4 || PointerSize == 8) &&
+               "Add support for other sizes if necessary");
+        return PointerSize;
+      };
----------------
Could this instead be "GetPointerSizedForm" and encapsulate the `PointerSize == 4 ? dwarf::DW_OP_const4u : dwarf::DW_OP_const8u` logic too?

Oh, I see there's both OP and FORM needed, not just FORM... maybe still nice to share?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D116480/new/

https://reviews.llvm.org/D116480



More information about the llvm-commits mailing list