[llvm-dev] Computing unique ID of IR instructions that can be mapped back

Dipanjan Das via llvm-dev llvm-dev at lists.llvm.org
Thu May 4 16:47:19 PDT 2017


I am writing an analysis pass on LLVM which requires to:

   [1] generate unique, positive ID corresponding to each instruction
   [2] the ID must survive across runs
   [3] given the ID, corresponding instruction has to be mapped back

For [1], the general suggestion is to use the Value* instr_ptr associated
to each instruction. The instr_ptr points to specific instruction in
memory, hence unique. However, it does change at every run, thus violating
[2]. I have a hacking workaround of getting the first instruction of 'main'
method and computing the offset. The problem is, this gives me negative
offset for instructions lying in lower memory region than 'main'. Even if I
circumvent the problem by adding a positive bias high enough, I have no
clue how can I map the instr_ptr back to corresponding IR instruction. Can
anyone suggest any elegant workaround?

-- 

Thanks & Regards,
Dipanjan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170504/0d96ba69/attachment.html>


More information about the llvm-dev mailing list