How to identify an instruction across different passes

Hi folks, recently, I’ve developed multiple passes based on llvm IR. Among them there is a complicated dependency, so, for the sake of modularity, I just finish one pass, write its result to file, and feed the result to a later pass. for example, a sophisticated call graph analysis is needed by many other passes, so I just write the call instructions(in its text presentation) associated with the functions it can potentially call.

This causes a performance issue which is not caused by file I/O(surprisingly) but by the fact that I used the text representation to mark an Instruction of interest.(so if the result is associated with an instruction, I just write its text representation to a file), and later after reading the file in, I compare it with the text of IR that I have, and the intensive getting the text presentation from the IR takes 97% of the rendering time.
I know this sounds kind of silly but, it seems there is no way to mark an instruction across different passes.
Does anyone has idea about this?

a small hack I found is quite useful,
if the IR stays intact across these different passes,
the index of the function, basicblock, and the instruction can be used to mark this instruction.
i.e., within a module, the offset of a function, basicblock, and instruction remains unchanged.

The rendering time of the callgraph dropped from more than one hour to just dozens of seconds.