Commit 41a6780
committed
Deprecate BasicBlock.delete() with a stern warning
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.1 parent 7bc5935 commit 41a6780
1 file changed
+16
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
75 | 71 | | |
76 | 72 | | |
77 | 73 | | |
| |||
87 | 83 | | |
88 | 84 | | |
89 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
90 | 98 | | |
91 | 99 | | |
92 | 100 | | |
| |||
0 commit comments