In PR24288 it was pointed out that the easy case of a non-escaping
global and something that *obviously* required an escape sometimes is
hidden behind PHIs (or selects in theory). Because we have this binary
test, we can easily just check that all possible input values satisfy
the requirement. This is done with a (very small) recursion through PHIs
and selects. With this, the specific example from the PR is correctly
folded by GVN.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/Analysis/IPA/GlobalsModRef.cpp | ||
---|---|---|
734 ↗ | (On Diff #31199) | colud -> could |
762 ↗ | (On Diff #31199) | It looks like this also covers the case where we end up reaching GV itself in the recursion. Perhaps make that explicit? |
806 ↗ | (On Diff #31199) | This looks a bit confusing. |
Updated, and responses to review comments below...
lib/Analysis/IPA/GlobalsModRef.cpp | ||
---|---|---|
698 ↗ | (On Diff #31199) | Sorry, I was trying to use GV to do some stuff that ended up with the FIXME comment instead. =] Based on Michael's comment, I'll add in the stub that uses it around the FIXME comment, which should also make it much more clear how to safely implement that FIXME. |
762 ↗ | (On Diff #31199) | Yea, that also gives me a much better place to anchor the FIXME above. Should make sure that we don't introduce a bug about the same GV when addressing that FIXME. |
806 ↗ | (On Diff #31199) | I really don't like the swap pattern... Does doing this in separate variable initializers make it more clear? (Patch updated to do that...) |