Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[LoopDeletion] Handle users in unreachable block
This is a fix for PR35884. When we want to delete dead loop we must clean uses in unreachable blocks otherwise we'll get an assert during deletion of instructions from the loop. Reviewers: anna, davide Reviewed By: anna Subscribers: llvm-commits, lebedev.ri Differential Revision: https://reviews.llvm.org/D41943 llvm-svn: 322357
- Loading branch information
Serguei Katkov
committed
Jan 12, 2018
1 parent
72001f4
commit a757d65
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
; RUN: opt < %s -loop-deletion -S | FileCheck %s | ||
|
||
; Checking that possible users of instruction from the loop in | ||
; unreachable blocks are handled. | ||
|
||
define i64 @foo() { | ||
entry: | ||
br label %invloop | ||
; CHECK-LABEL-NOT: invloop | ||
invloop: | ||
%indvar1 = phi i64 [ 3, %entry ], [ %indvar2, %invloop_iter ] | ||
%check = icmp ult i64 %indvar1, 400 | ||
br i1 %check, label %invloop_iter, label %loopexit | ||
invloop_iter: | ||
%indvar2 = add i64 %indvar1, 1 | ||
%baddef = add i64 0, 0 | ||
br label %invloop | ||
loopexit: | ||
ret i64 0 | ||
deadcode: | ||
; CHECK-LABEL: deadcode | ||
; CHECK: ret i64 undef | ||
ret i64 %baddef | ||
} |