Changeset 207408 in webkit


Ignore:
Timestamp:
Oct 17, 2016 9:19:10 AM (8 years ago)
Author:
fpizlo@apple.com
Message:

Air::IRC needs to place all Tmps on some worklist, even if they have no interference edges
https://bugs.webkit.org/show_bug.cgi?id=163509

Reviewed by Mark Lam.

The worklist building function in IRC skips temporaries that have no degree. This doesn't appear
to be necessary. This has been there since the original IRC commit. It hasn't caused bugs because
ordinarily, the only way to have a tmp with no degree is to not have any mention of that tmp. But
while working on bug 163371, I hit a crazy corner case where a temporary would have no
interference edges (i.e. no degree). Here's how it happens:

A spill tmp from a previous iteration of IRC may have no degree: imagine a tmp that is live
everywhere and interferes with everyone, but has one use like:

Move %ourTmp, %someOtherTmp

Where there are no other tmps live. After spill conversion, this may look like:

Move (ourSpill), %newTmp
Move %newTmp, %someOtherTmp

Of course, we'd rather not get this kind of spill code but it's totally possible because we now
have a bunch of random conditions under which we won't slap the spill address directly into the
Move.

After this happens, assuming that the only thing live was %someOtherTmp, we will have zero degree
for %newTmp because the Move is coalescable and does not contribute to interference.

Then, we might coalesce %someOtherTmp with %newTmp. Once this happens, if we make the %newTmp be
the master, we're in deep trouble because %newTmp is not on any worklist.

I don't know how to reproduce this except through the patch in bug 163371. Removing the two lines
of code that skipped no-degree tmps causes no regressions, and resolves the problem I was having.

  • b3/air/AirIteratedRegisterCoalescing.cpp:
Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r207387 r207408  
     12016-10-16  Filip Pizlo  <fpizlo@apple.com>
     2
     3        Air::IRC needs to place all Tmps on some worklist, even if they have no interference edges
     4        https://bugs.webkit.org/show_bug.cgi?id=163509
     5
     6        Reviewed by Mark Lam.
     7       
     8        The worklist building function in IRC skips temporaries that have no degree. This doesn't appear
     9        to be necessary. This has been there since the original IRC commit. It hasn't caused bugs because
     10        ordinarily, the only way to have a tmp with no degree is to not have any mention of that tmp. But
     11        while working on bug 163371, I hit a crazy corner case where a temporary would have no
     12        interference edges (i.e. no degree). Here's how it happens:
     13       
     14        A spill tmp from a previous iteration of IRC may have no degree: imagine a tmp that is live
     15        everywhere and interferes with everyone, but has one use like:
     16
     17        Move %ourTmp, %someOtherTmp
     18
     19        Where there are no other tmps live.  After spill conversion, this may look like:
     20
     21        Move (ourSpill), %newTmp
     22        Move %newTmp, %someOtherTmp
     23
     24        Of course, we'd rather not get this kind of spill code but it's totally possible because we now
     25        have a bunch of random conditions under which we won't slap the spill address directly into the
     26        Move.
     27
     28        After this happens, assuming that the only thing live was %someOtherTmp, we will have zero degree
     29        for %newTmp because the Move is coalescable and does not contribute to interference.
     30
     31        Then, we might coalesce %someOtherTmp with %newTmp.  Once this happens, if we make the %newTmp be
     32        the master, we're in deep trouble because %newTmp is not on any worklist.
     33       
     34        I don't know how to reproduce this except through the patch in bug 163371. Removing the two lines
     35        of code that skipped no-degree tmps causes no regressions, and resolves the problem I was having.
     36
     37        * b3/air/AirIteratedRegisterCoalescing.cpp:
     38
    1392016-10-15  Mark Lam  <mark.lam@apple.com>
    240
  • trunk/Source/JavaScriptCore/b3/air/AirIteratedRegisterCoalescing.cpp

    r207004 r207408  
    8989        for (IndexType i = firstNonRegIndex; i < m_degrees.size(); ++i) {
    9090            unsigned degree = m_degrees[i];
    91             if (!degree)
    92                 continue;
    93 
    9491            if (degree >= m_regsInPriorityOrder.size())
    9592                addToSpill(i);
Note: See TracChangeset for help on using the changeset viewer.