When we collect 2 uses of a function in FindUses and then RAUW when we visit
the first, we end up visiting the wrapper (because the second was RAUW'd).
We still want to use RAUW instead of just Use->set() because it has special handling for
Constants, so this patch just ensures that only one use of each constant is added to the work list.
Details
Diff Detail
- Build Status
Buildable 2791 Build 2791: arc lint + arc unit
Event Timeline
The alternative would of course be to just collect the uses in a set, deduplicated by callee, and then RAUW everything. But I'm actually unclear why the original has distinction between whether the user is a constant or not; it seems to work either way for me locally?
OK, actually I forgot that our use list doesn't contain all the uses, just the ones with mismatched types. So RAUWing when U is a constant was intended to really just replaces the uses within the one constexpr? but because of uniquing it affects the other calls as well and we visit that use again.
Constants are meant to be immutable at some level in LLVM, so my idea with the RAUW was to avoid mutating them (RAUW has special logic for constants so that it doesn't actually mutate them). However, you're right that this breaks when there are multiple uses of the same function.