forked from rust-lang/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IR][LoopRotate] avoid leaving phi with no operands (PR48296)
https://llvm.org/PR48296 shows an example where we delete all of the operands of a phi without actually deleting the phi, and that is currently considered invalid IR. The reduced test included here would crash for that reason. A suggested follow-up is to loosen the assert to allow 0-operand phis in unreachable blocks. Differential Revision: https://reviews.llvm.org/D92247
- Loading branch information
1 parent
234a529
commit bfd2c21
Showing
3 changed files
with
38 additions
and
4 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
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,34 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py | ||
; RUN: opt -S -lcssa -loop-rotate < %s | FileCheck %s | ||
|
||
define void @PR48296(i1 %cond) { | ||
; CHECK-LABEL: @PR48296( | ||
; CHECK-NEXT: entry: | ||
; CHECK-NEXT: br label [[LOOP:%.*]] | ||
; CHECK: loop: | ||
; CHECK-NEXT: br i1 [[COND:%.*]], label [[INC:%.*]], label [[LOOP_BACKEDGE:%.*]] | ||
; CHECK: loop.backedge: | ||
; CHECK-NEXT: br label [[LOOP]] | ||
; CHECK: dead: | ||
; CHECK-NEXT: unreachable | ||
; CHECK: inc: | ||
; CHECK-NEXT: br label [[LOOP_BACKEDGE]] | ||
; CHECK: return: | ||
; CHECK-NEXT: ret void | ||
; | ||
entry: | ||
br label %loop | ||
|
||
loop: | ||
br i1 %cond, label %inc, label %loop | ||
|
||
dead: ; No predecessors! | ||
br i1 %cond, label %inc, label %return | ||
|
||
inc: | ||
br label %loop | ||
|
||
return: | ||
%r = phi i32 [ undef, %dead ] | ||
ret void | ||
} |