[PATCH] D87149: [InstCombine] erase instructions leading up to unreachable
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 18 10:00:18 PDT 2020
spatel added a comment.
In D87149#2281145 <https://reviews.llvm.org/D87149#2281145>, @uabelho wrote:
> Hi!
>
> We've run into a case where instcombine crashes with this patch:
>
> opt -o /dev/null bbi-47401.ll -instcombine
>
> on
>
> @c = external global i16*, align 1
>
> define void @main() {
> entry:
> br label %for.cond
>
> for.cond: ; preds = %g.exit, %entry
> %conv1 = phi double [ %conv, %g.exit ], [ undef, %entry ]
> br i1 undef, label %for.end, label %for.body
>
> for.body: ; preds = %for.cond
> %0 = load i16*, i16** @c, align 1
> %1 = load i16, i16* %0, align 1
> %conv = sitofp i16 %1 to double
> unreachable
>
> g.exit: ; No predecessors!
> br label %for.cond
>
> for.end: ; preds = %for.cond
> %conv1.lcssa = phi double [ %conv1, %for.cond ]
> store double %conv1.lcssa, double* undef, align 1
> ret void
> }
>
> results in
>
> opt: ../lib/Transforms/InstCombine/InstCombineInternal.h:448: virtual llvm::Instruction *llvm::InstCombinerImpl::eraseInstFromFunction(llvm::Instruction &): Assertion `I.use_empty() && "Cannot erase instruction that is used!"' failed.
>
> I suppose it's the dead block %g.exit that messes up things.
We had a use_empty() guard in an earlier draft of this patch and decided that could not happen. :)
https://reviews.llvm.org/D87149#2259207
Thanks for the test case!
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87149/new/
https://reviews.llvm.org/D87149
More information about the llvm-commits
mailing list