During the optimisation of jump tables in the constant island pass,
an extra ADD could be left over, now dead but not removed.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/Target/ARM/ARMConstantIslandPass.cpp | ||
---|---|---|
2033 ↗ | (On Diff #93110) | I'm confused. This means the else part will only execute one iteration after the add is detected. Assuming ADD is never the last instruction (because the last is JumpMI), this should be ok, but I'm not sure why it's necessary, and it makes the code flow harder to understand. Also, if there are multiple adds, this would overwrite the RemovableAdd pointer *before* it was sure the new ADD can be removed. I'd make the whole iteration in one go, on a local pointer, and only update the higher scope pointer once the add is really the one we're looking for. Would it be an error if we find two adds in the right condition? |
Hello, thanks for the suggestions.
The idea behind the loop is to find the last ADD that sets EntryReg (the register that the JT uses), providing EntryReg is not used or def'd between the ADD and the JT. I've split it up into two loops to make it more parsable. This is in a way just an attempt to improve preserveBaseRegister above, but when I tried to implement this in there it came out as a bit of a mess, and was no longer just doing "Preserve Base Register" stuff. Apparently the new function wasn't much better though!
Let me know what you think, cheers
Dave