[llvm] [DominanceFrontier] make iterating dereferenced DominanceFrontierBase::find deterministic (PR #69711)

Wenju He via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 23 03:04:51 PDT 2023


wenju-he wrote:

> The description says it makes the `DominanceFrontierBase::find` iterator deterministic, but `find` returns an iterator to the map, not the set you are changing?

Yes, `find` returns an iterator to the map. I meant that when I dereference the iterator and then iterator over the dereferenced value which is a set.
I've updated title and commit message.

> I am a bit curious why this issue hasn't shown up before with current in tree users

I find that the main use of DominanceFrontierBase is in class DominanceFrontier and MachineDominanceFrontier.

DominanceFrontierAnalysis is used in RegionInfo, the two following uses of `find` needn't to care about order:
https://github.com/llvm/llvm-project/blob/3651f377f632d9152f2bd8fc2f9302ec9f9bdd5e/llvm/include/llvm/Analysis/RegionInfoImpl.h#L571-L579
https://github.com/llvm/llvm-project/blob/3651f377f632d9152f2bd8fc2f9302ec9f9bdd5e/llvm/include/llvm/Analysis/RegionInfoImpl.h#L584-L594

I found two uses of `DomSetType` in MachineDominanceFrontier, and both of them only use set member functions and thus needn't to care about order:
https://github.com/llvm/llvm-project/blob/8291147356e5bc81d5bd3b904e760c689543dc9a/llvm/include/llvm/CodeGen/MachineDominanceFrontier.h#L77
https://github.com/llvm/llvm-project/blob/8291147356e5bc81d5bd3b904e760c689543dc9a/llvm/include/llvm/CodeGen/MachineDominanceFrontier.h#L93

> if there's some way we can test this in upstream.

This is a good suggestion. Unfortunately I don't have idea at the moment.

https://github.com/llvm/llvm-project/pull/69711


More information about the llvm-commits mailing list