[PATCH] D156226: [DebugInfo] Fix crash when printing malformed DBG machine instructions

Jeremy Morse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 25 04:02:51 PDT 2023


jmorse added a comment.

This sounds like a good direction to take. As for why the verifier doesn't check things, IIRC there are some MIR tests out there where we don't bother to feed in any metadata, so that you can put meaningless `DBG_VALUE`'s in MIR tests to test behaviours with little overhead. And which then leads to the behaviour you're patching against here.

Just to confirm my understanding: this is only suppressing printing the operands of debug instructions when there aren't enough operands, yes? It'd be unfortunate if we completely skipped printing an instruction because it was malformed, thus hiding it from developers.



================
Comment at: llvm/lib/CodeGen/MachineInstr.cpp:1886-1889
+  // Print extra comments for DEBUG_VALUE and friends if they are well-formed.
+  if ((isNonListDebugValue() && getNumOperands() == 4) ||
+      (isDebugValueList() && getNumOperands() == 2) ||
+      (isDebugRef() && getNumOperands() == 3)) {
----------------
I believe these should be `>=` operators rather than `==` . The instructions that can be variadic may have several operands or none, and we want  the Variable and DebugLoc printed in those scenarios.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156226



More information about the llvm-commits mailing list