Generating Consistent Instruction IDs

Hi,

I'd like to ask you what's the best way of generating instruction
identifiers which are consistent across independent invocations of the
LLVM program. One way would be to use a counter and iterate over all
the functions, then all the BBs. But are there any guarantees on the
ordering of the functions and BBs in the iteration? In extremis, I can
sort the functions after name, but what about the basic blocks?

Thanks!

Stefan Bucur

How do you intend to use these IDs ?

For tracking cumulative code coverage across multiple executions. Each
ID would be an index into a bitfield, so I would need the same ID to
refer to the same instruction from one execution to the other.

Stefan

It seems like a hash of the function number and the offset of the instruction into the function would do the trick.

The compiler should generate exactly the same code on multiple invocations over the same input, including ordering. If it doesn't, something non deterministic is going on somewhere, which is a bad thing (and a bug). If you're varying the input to the compiler, then all bets are off, of course.

Regards,
  Jim