Skip to content

[move-function] Break blocks right after the non-undef debug info associated with move only values. #41515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

gottesmm
Copy link
Contributor

NOTE: This PR contains 3 commits. The initial commit is the meaty commit and I included in the body of this PR msg the commit message from that commit. The other two later commits are just some cleanups to the code that I split from the first commit to make it easier to understand the first commit.


[move-function] Break blocks right after the non-undef debug info associated with move only values.

The reason why I am doing this is that right now SelectionDAG seems to sink
certain llvm.dbg.addr to the end of block. By breaking the block, we ensure that
we initialize the debug value of values early enough. NOTE: We are relying on
code at -Onone not eliminating control flow which it does not today.

A few additional notes:

  1. I also fixed a small issue where I was not setting the proper debug scope for
    reinit debug_values. This came up when I was writing test cases for this commit.
    So I just fixed it at the same time.

  2. Since I am splitting blocks and I don't want to invalidate dominators/etc at
    this point in the pipeline, I took advantage of the APIs ability to update
    dominators/loopinfo at the same time.

  3. I also expanded the tests in tree further by adding debug info tests for the
    reinit copyable/addressonly cases in the multi-block case.

@gottesmm
Copy link
Contributor Author

@swift-ci test

@gottesmm gottesmm requested a review from atrick February 22, 2022 21:51
@gottesmm gottesmm force-pushed the pr-2d2da2179be796c2147236db824f24b137037bdb branch from 6e5809e to 693fded Compare February 22, 2022 22:03
@gottesmm
Copy link
Contributor Author

@swift-ci test

…ociated with move only values.

The reason why I am doing this is that right now SelectionDAG seems to sink
certain llvm.dbg.addr to the end of block. By breaking the block, we ensure that
we initialize the debug value of values early enough. NOTE: We are relying on
code at -Onone not eliminating control flow which it does not today.

A few additional notes:

1. I also fixed a small issue where I was not setting the proper debug scope for
reinit debug_values. This came up when I was writing test cases for this commit.
So I just fixed it at the same time.

2. Since I am splitting blocks and I don't want to invalidate dominators/etc at
this point in the pipeline, I took advantage of the APIs ability to update
dominators/loopinfo at the same time.

3. I also expanded the tests in tree further by adding debug info tests for the
reinit copyable/addressonly cases in the multi-block case.
…inst->callMethod() to debug->callMethod().

DebugVarCarryingInst provides this light weight API... lets use it to shrink our
code!

NFC.
… checker instead of a free function.

This lets me simplify the code by eliminating 2 arguments we were already
passing in from the checker.

NFC.
@gottesmm gottesmm force-pushed the pr-2d2da2179be796c2147236db824f24b137037bdb branch from 693fded to 13518c5 Compare February 22, 2022 22:06
@@ -1538,8 +1543,13 @@ bool DataflowState::cleanupAllDestroyAddr(
if (debugVarInst) {
if (auto varInfo = debugVarInst.getVarInfo()) {
SILBuilderWithScope reinitBuilder(*reinit);
reinitBuilder.createDebugValue(debugVarInst.inst->getLoc(), address,
*varInfo, false, /*was moved*/ true);
reinitBuilder.setCurrentDebugScope(debugVarInst->getDebugScope());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the reinit fix I mention in the commit msg.

static bool performSingleBasicBlockAnalysis(DataflowState &dataflowState,
SILValue address,
MarkUnresolvedMoveAddrInst *mvi) {
static bool performSingleBasicBlockAnalysis(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the later commit, I change this to be a method to remove the globals I am passing in here.

@gottesmm
Copy link
Contributor Author

@swift-ci test

@gottesmm
Copy link
Contributor Author

Added a last commit that updates the moveonly_builtin test.

@gottesmm
Copy link
Contributor Author

@swift-ci test

@gottesmm gottesmm merged commit 210e135 into swiftlang:main Feb 23, 2022
@gottesmm gottesmm deleted the pr-2d2da2179be796c2147236db824f24b137037bdb branch February 23, 2022 04:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant