Skip to content

Reconcile handling of EH vars - #1884

Merged
CarolEidt merged 4 commits into
dotnet:masterfrom
CarolEidt:Fix1786
Jan 22, 2020
Merged

CarolEidt merged 4 commits into
dotnet:masterfrom
CarolEidt:Fix1786

Conversation

@CarolEidt

Copy link
Copy Markdown
Contributor

Modify BasicBlock::hasEHBoundaryIn() and BasicBlock::hasEHBoundaryOut() to reflect what liveness is doing, and change liveness to call those methods, and adjust the register allocator code appropriately.

It might make sense to extract the code that's basically the same, except that the register allocator doesn't need the finallyVars except as validation in the DEBUG case.

Fix #1786

@CarolEidt

Copy link
Copy Markdown
Contributor Author

Also, fix STRESS_RANDOM_INLINE to work when set with COMPlus_JitStressModeNames not just with COMPlus_JitStress.

@CarolEidt

Copy link
Copy Markdown
Contributor Author

@dotnet/jit-contrib PTAL - will still want to run stress testing on this if all the innerloop passes.

@jkotas jkotas added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jan 18, 2020
Comment thread src/coreclr/src/jit/block.cpp Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not too fond of "Last" in the name -- it seems ambiguous what it is last with respect to: last in the function?

How about "Tail" instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense.

Comment thread src/coreclr/src/jit/block.cpp Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would be better as:

return (bbPrev != nullptr) && bbPrev->isBBCallAlwaysPair();

There are other places that could use this, e.g. in optAddCopies:

#if defined(FEATURE_EH_FUNCLETS)
                    // With funclets, this is only used for BBJ_CALLFINALLY/BBJ_ALWAYS pairs. For x86, it is also used
                    // as the "final step" block for leaving finallys.
                    assert((block->bbPrev != nullptr) && block->bbPrev->isBBCallAlwaysPair());
#endif // FEATURE_EH_FUNCLETS

and EHSuccessorIterPosition:

        BasicBlock* beforeBlock = block->bbPrev;
        if (beforeBlock != nullptr && beforeBlock->isBBCallAlwaysPair())
        {
            m_curTry = nullptr;
        }

there are more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll modify the condition - I think that using this in other places might be better left as a "clean up" PR that also includes the liveness changes.

Comment thread src/coreclr/src/jit/liveness.cpp Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're no longer adding to filterVars for BBJ_EHFILTERRET.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filterVars is not separately used, and can be combined with exceptVars since they are tested with an || condition.

Comment thread src/coreclr/src/jit/liveness.cpp Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You removed this, but the hasEHBoundaryIn() case above doesn't replace it for filter/finally/fault funclets.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that you had indicated to me that a block with BBF_FUNCLET_BEG set would always have bbCatchTyp != BBCT_NONE, so this was changed to an assert for the hasEHBoundaryIn() case - is there something else I've missed?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right, I forgot about the special BBCT values for fault/finally/filter/filter-handler.

@BruceForstall

Copy link
Copy Markdown
Contributor

The liveness changes are nice (if complete), but not necessary to fix the bug that's making the CI pipelines fail. Could they be moved to a separate PR?

Modify `BasicBlock::hasEHBoundaryIn()` and `BasicBlock::hasEHBoundaryOut()` to reflect what liveness is doing, and change liveness to call those methods, and adjust the register allocator code appropriately.

It might make sense to extract the code that's basically the same, except that the register allocator doesn't need the `finallyVars` except as validation in the `DEBUG` case.

Fix dotnet#1786
@CarolEidt
CarolEidt merged commit e686c07 into dotnet:master Jan 22, 2020
@CarolEidt
CarolEidt deleted the Fix1786 branch January 27, 2020 18:12
@ghost ghost locked as resolved and limited conversation to collaborators Dec 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Assertion failed 'varDsc->lvLiveInOutOfHndlr'

3 participants