How to efficiently compute ordering of two SILInstructions?

i've been looking into some of the proposed improvements for DI performance outlined here, but have run into an issue i don't quite understand how to handle. specifically, if i have two SILInstructions that are known to have the same parent, is there a way to determine their ordering without walking the underlying list of instructions in the block? i've sort of assumed this should be possible since when i look at SILGen output, there are increasing ids for the instruction values[1], but i haven't determined if/how that information can be used for this purpose.


  1. not sure if this is the correct terminology, but the things like %2, %3, etc ↩︎

it seems i may have been mistaken in my assumption that there is a way to do this based on the fact that there are increasing 'identifier' values printed in the SILGen output. i was informed that this is a byproduct of the logic in SILPrinter which also does a traversal of all blocks/instructions to generate those values.

so, i will assume this isn't possible to do without some form of local cache derived from walking the instructions at least once.