# Adding instruction ids in debug dumps

**URL:** <https://discourse.llvm.org/t/adding-instruction-ids-in-debug-dumps/68188>\
**Category:** IR & Optimizations\
**Tags:** core\
**Created:** [February 4, 2023, 3:40pm UTC](https://discourse.llvm.org/t/adding-instruction-ids-in-debug-dumps/68188 "2023-02-04T15:40:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yugr](https://sea1.discourse-cdn.com/flex021/user_avatar/discourse.llvm.org/yugr/32/2507_2.png) [@yugr](https://discourse.llvm.org/u/yugr)\
**Post date:** [February 4, 2023, 3:40pm UTC](https://discourse.llvm.org/t/adding-instruction-ids-in-debug-dumps/68188/1 "2023-02-04T15:40:21Z")

</div>

Hi all,

During analysis of IR/MIR dumps I sometimes need to investigate behavior of a particular problematic instruction.

To my knowledge there is currently no easy way to map from instruction in dumpfile to a place where it’s created or modified in the compiler.

One simple solution to this which I’ve seen in the past is to add instruction UIDs which could be printed in dumps and then used for setting conditional breakpoints in debugger. Would something like this make sense for mainline?

I’ve put a simple PR at [⚙ D143321 [DRAFT] [IR] Add instruction IDs to simplify debugging.](https://reviews.llvm.org/D143321) to illustrate this suggestion.

Best regards,  
Yuri

---

<div class="post-metadata">

**Author:** ![nhaehnle](https://sea1.discourse-cdn.com/flex021/user_avatar/discourse.llvm.org/nhaehnle/32/23079_2.png) [@nhaehnle](https://discourse.llvm.org/u/nhaehnle)\
**Post date:** [February 6, 2023, 1:22pm UTC](https://discourse.llvm.org/t/adding-instruction-ids-in-debug-dumps/68188/2 "2023-02-06T13:22:04Z")

</div>

Have you considered attaching metadata to the instructions instead?

---

<div class="post-metadata">

**Author:** ![yugr](https://sea1.discourse-cdn.com/flex021/user_avatar/discourse.llvm.org/yugr/32/2507_2.png) [@yugr](https://discourse.llvm.org/u/yugr)\
**Post date:** [February 7, 2023, 6:15pm UTC](https://discourse.llvm.org/t/adding-instruction-ids-in-debug-dumps/68188/3 "2023-02-07T18:15:56Z")

</div>

No, I have not. Thank you for the suggestion, I’ll give it a try.

I think my main concern is whether this is appropriate for trunk in general. In my opinion this feature is useful in debugging but I may be wrong.
