This is an archive of the discontinued LLVM Phabricator instance.

[RegisterCoalescing] Don't move COPY if it would interfere with another value
ClosedPublic

Authored by uabelho on Mar 26 2018, 11:46 PM.

Details

Summary

RegisterCoalescer::removePartialRedundancy tries to hoist B = A from
BB0/BB2 to BB1:

BB1:
     ...
BB0/BB2:  ----
     B = A;   |
     ...      |
     A = B;   |
       |-------
       |

It does so if a number of conditions are fulfilled. However, it failed
to check if B was used by any of the terminators in BB1. Since we must
insert B = A before the terminators (since it's not a terminator itself),
this means that we could erroneously insert a new definition of B before a
use of it.

Diff Detail

Repository
rL LLVM

Event Timeline

uabelho created this revision.Mar 26 2018, 11:46 PM
wmi accepted this revision.Mar 27 2018, 10:12 PM

LGTM. Thanks for the fix.

This revision is now accepted and ready to land.Mar 27 2018, 10:12 PM
This revision was automatically updated to reflect the committed changes.
In D44918#1050096, @wmi wrote:

LGTM. Thanks for the fix.

Thank you for the review!

arsenm added a subscriber: arsenm.Aug 18 2023, 3:38 PM
arsenm added inline comments.
llvm/trunk/test/CodeGen/Mips/coalesce-partial-redundant-reguse-terminator.mir
1

This testcase is invalid and fails the verifier with -verify-coalescing. I'm not sure how to reproduce the original problem while preserving correct value numbering

Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptAug 18 2023, 3:38 PM