Skip to content

Deprecate BasicBlock.delete() with a stern warning #83

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
merged 1 commit into from
Mar 30, 2017

Conversation

CodaFi
Copy link
Member

@CodaFi CodaFi commented Mar 29, 2017

Deprecates BasicBlock.delete() and marks it for removal at a later date when we figure this out. I'm going to submit a corresponding pull request to Trill to resolve the issues we've been seeing related to this API.

Removing blocks from the CFG is not as easy as it might appear at
first.  Incorrect deletion of a block can cause dangling references to
appear in the function which show up as bad accesses when deallocation
of the parent function occurs.

The safest way to remove a Basic Block is to first make sure that it is
freshly inserted.  Next, walk its instructions and, in turn, their uses
and overwrite those uses with undef.  Next, remove those instructions
from the basic block one by one.  Finally, call removeFromParent().  Do
not attempt to delete() the block, the containing function will handle
that when it goes to destroy the module.
@CodaFi
Copy link
Member Author

CodaFi commented Mar 30, 2017

⛵️

@CodaFi CodaFi merged commit 4b12d9a into llvm-swift:master Mar 30, 2017
@CodaFi CodaFi deleted the trash-removal branch March 30, 2017 05:37
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.

2 participants