forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CanonicalizeFreezeInLoops] fix duplicate removal (llvm#74716)
This PR fixes llvm#74572 where the freeze instruction could be found twice by the pass CanonicalizeFreezeInLoops, and then the compiling may crash in second removal since the instruction has already gone.
- Loading branch information
1 parent
fb981e6
commit a700298
Showing
2 changed files
with
76 additions
and
16 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
32 changes: 32 additions & 0 deletions
32
llvm/test/Transforms/CanonicalizeFreezeInLoops/duplicate_remove.ll
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,32 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4 | ||
; RUN: opt < %s --passes=canon-freeze -S | FileCheck %s | ||
|
||
define void @check_duplicate_removal(i32 %n) { | ||
; CHECK-LABEL: define void @check_duplicate_removal( | ||
; CHECK-SAME: i32 [[N:%.*]]) { | ||
; CHECK-NEXT: entry: | ||
; CHECK-NEXT: [[N_FROZEN:%.*]] = freeze i32 [[N]] | ||
; CHECK-NEXT: br label [[LOOP:%.*]] | ||
; CHECK: loop: | ||
; CHECK-NEXT: [[T1:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[T3:%.*]], [[LOOP]] ] | ||
; CHECK-NEXT: [[T2:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ [[T3]], [[LOOP]] ] | ||
; CHECK-NEXT: [[T3]] = add i32 [[N_FROZEN]], [[T2]] | ||
; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 [[T2]], 0 | ||
; CHECK-NEXT: br i1 [[COND]], label [[LOOP]], label [[EXIT:%.*]] | ||
; CHECK: exit: | ||
; CHECK-NEXT: ret void | ||
; | ||
entry: | ||
br label %loop | ||
|
||
loop: | ||
%t1 = phi i32 [ 0, %entry], [%t3, %loop ] | ||
%t2 = phi i32 [ 0, %entry], [%t3, %loop ] | ||
%t3 = add i32 %n, %t2 | ||
%.fr = freeze i32 %t3 | ||
%cond = icmp eq i32 %t2, 0 | ||
br i1 %cond, label %loop, label %exit | ||
|
||
exit: | ||
ret void | ||
} |