[PATCH] D63972: [CodeGen] Do the Simple Early Return in block-placement pass to optimize the blocks
Zhang Kang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 31 00:06:53 PDT 2019
ZhangKang added a comment.
In D63972#1606967 <https://reviews.llvm.org/D63972#1606967>, @efriedma wrote:
> > Here, if I use F->erase(TBB), the memory leak error is still existed.
>
> What exactly is leaking? (If you're calling erase(), it isn't the MBB itself.)
>
> Of course, that isn't a substitute for calling `FunctionChain.remove` etc.
>
> Looking over this patch again, some of the other work involved in updating various data structures isn't complete here; the MachineDominatorTree/MachinePostDominatorTree isn't updated, MachineLoopInfo isn't updated.
I have made a mistake to say `if I use F->erase(TBB), the memory leak error is still existed.`.
The memory leak is TBB. I should say that if I use `F->remove()`, I will get `memory leak error`, but If use `F->erase(TBB)`, the `memory leak error` will disappear, but I will get `ERROR: AddressSanitizer: use-after-poison`.
Analyse the `ERROR: AddressSanitizer: use-after-poison` when using `F->erase(TBB)`
2714 for (MachineBasicBlock *ChainBB : FunctionChain) {
2715 Cond.clear();
2716 MachineBasicBlock *TBB = nullptr, *FBB = nullptr; // For AnalyzeBranch.
2717 if (!TII->analyzeBranch(*ChainBB, TBB, FBB, Cond, /*AllowModify*/ true)) {
If I use `F->erase(TBB)`, the `FunctionChain` still has the element which I have removed, so I will get the `ERROR: AddressSanitizer: use-after-poison` when call `2717 if (!TII->analyzeBranch(*ChainBB, TBB, FBB, Cond, /*AllowModify*/ true)) {`.
I should remember those empty BasicBlocks, and do the clean work after the `2714 for loop` exit.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D63972/new/
https://reviews.llvm.org/D63972
More information about the llvm-commits
mailing list