[CaptureTracking] Correctly handle multiple uses in one instruction
authorNikita Popov <nikita.ppv@gmail.com>
Sat, 7 Nov 2020 10:19:27 +0000 (11:19 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Sat, 7 Nov 2020 10:31:20 +0000 (11:31 +0100)
commitd35366bccae0016418660337ce94e3d7d0ff391e
treea3f39f4b731062993de15f1f773b7bcfa93924ce
parent89eed79c1fa801f4254c3b20aee6185b274180f4
[CaptureTracking] Correctly handle multiple uses in one instruction

If the same value is used multiple times in the same instruction,
CaptureTracking may end up reporting the wrong use as being captured,
and/or report the same use as being captured multiple times.

Make sure that all checks take the use operand number into account,
rather than performing unreliable comparisons against the used value.

I'm not sure whether this can cause any problems in practice, but
at least some capture trackers (ArgUsesTracker, AACaptureUseTracker)
do care about which call argument is captured.
llvm/lib/Analysis/CaptureTracking.cpp
llvm/unittests/Analysis/CaptureTrackingTest.cpp