[PATCH] D69865: [IR] PR27065: Part2. Fix BasicBlock::removePredecessor to not break SSA form.
Johannes Doerfert via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 7 09:23:08 PST 2019
jdoerfert added a comment.
In D69865#1737198 <https://reviews.llvm.org/D69865#1737198>, @dendibakh wrote:
> > A same/similar question about this code in BasicBlock was raised on llvm-dev here:
> > http://lists.llvm.org/pipermail/llvm-dev/2015-August/089091.html
> >
> > Unfortunately, I don't think the legality of the invalid SSA is documented anywhere. But as we can see, it passes the IR verifier.
> >
> > As noted in D69823 <https://reviews.llvm.org/D69823>, I've made several patches to other passes to work-around the issue. It would be great if we didn't have to do that, but AFAIK, we're stuck.
>
> Thanks for the link Sanjay,
The most common way to make sure passes do not choke on unreachable IR is to replace the loop
`for (BasicBlock &BB : Fn)`
with
`for (BasicBlock &BB: depth_first(Fn))`
which will never visit the unreachable parts.
> However, it's still not clear to me why broken unreachable code is better than valid unreachable code?
Because you have to add logic all over the place to ensure this condition.
> Is it a hidden way to test that passes do not look into unreachable code?
Not that I know of. You can write a test case with really broken unreachable IR and run all passes on it. That would actually be a really cool thing to do.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69865/new/
https://reviews.llvm.org/D69865
More information about the llvm-commits
mailing list