Skip to content

Conversation

adrian-prantl
Copy link
Contributor

What's in this pull request?

Debugging: Extend the live ranges of local values at -Onone.

For many local values we can avoid a shadow alloca by directly
describing them with a dbg.value. This also enables precise liveness
so variables don't show up in the debugger before they are
initialized. Unfortunately this also means that values will disappear
when they are no longer needed.

This patch inserts an empty inline assembler expression depending on
the llvm::Value that is being described in the blocks dominated by it.
This uses less stack space than full shadow copies *and* allows us to
track the liveness of the variable completely. It may cause values to
be spilled onto the stack, though.

<rdar://problem/26627376>

Resolved bug number: rdar://problem/26627376


Before merging this pull request to apple/swift repository:

  • Test pull request on Swift continuous integration.

Triggering Swift CI

@swift-ci Please test and merge

@adrian-prantl
Copy link
Contributor Author

@swift-ci Please test and merge

@adrian-prantl
Copy link
Contributor Author

@swift-ci Please test and merge

1 similar comment
@adrian-prantl
Copy link
Contributor Author

@swift-ci Please test and merge

For many local values we can avoid a shadow alloca by directly
describing them with a dbg.value. This also enables precise liveness
so variables don't show up in the debugger before they are
initialized. Unfortunately this also means that values will disappear
when they are no longer needed.

This patch inserts an empty inline assembler expression depending on
the llvm::Value that is being described in the blocks dominated by it.
This uses less stack space than full shadow copies *and* allows us to
track the liveness of the variable completely. It may cause values to
be spilled onto the stack, though.

<rdar://problem/26627376>
@adrian-prantl
Copy link
Contributor Author

@swift-ci Please test and merge

@jrose-apple
Copy link
Contributor

Won't this break bitcode?

@adrian-prantl
Copy link
Contributor Author

Legitimate question! It won't, because empty inline assembler expressions are ignored.

Note that we're already playing similar tricks in IRGenSILFunction::visitCondFailInst() and IRGenModule::getObjCRetainAutoreleasedReturnValueMarker() to defeat optimizations.

@swift-ci swift-ci merged commit 243e5a7 into swiftlang:master Jun 24, 2016
@jrose-apple
Copy link
Contributor

Good to know, thank you!

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.

3 participants