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.
[LICM] allow MemoryAccess creation failure (llvm#116813)
Fixes llvm#116809. After running some passes (SimpleLoopUnswitch, LoopInstSimplify, etc.), MemorySSA might be outdated, and the instruction `I` may have become a non-memory touching instruction. LICM has already handled this, but it does not pass `CreationMustSucceed=false` to `createDefinedAccess`.
- Loading branch information
Showing
4 changed files
with
61 additions
and
5 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
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,50 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt -passes='loop-mssa(simple-loop-unswitch<nontrivial>,licm)' -verify-memoryssa -S < %s | FileCheck %s | ||
|
||
; Check that running LICM after SimpleLoopUnswitch does not result in a crash. | ||
|
||
define i32 @foo(i1 %arg, ptr %arg1) { | ||
; CHECK-LABEL: define i32 @foo( | ||
; CHECK-SAME: i1 [[ARG:%.*]], ptr [[ARG1:%.*]]) { | ||
; CHECK-NEXT: [[START:.*:]] | ||
; CHECK-NEXT: [[ARG_FR:%.*]] = freeze i1 [[ARG]] | ||
; CHECK-NEXT: br i1 [[ARG_FR]], label %[[START_SPLIT_US:.*]], label %[[START_SPLIT:.*]] | ||
; CHECK: [[START_SPLIT_US]]: | ||
; CHECK-NEXT: br label %[[LOOP_US:.*]] | ||
; CHECK: [[LOOP_US]]: | ||
; CHECK-NEXT: br label %[[BB0:.*]] | ||
; CHECK: [[BB0]]: | ||
; CHECK-NEXT: br label %[[BB1:.*]] | ||
; CHECK: [[BB1]]: | ||
; CHECK-NEXT: [[UNSWITCHED_SELECT_US:%.*]] = phi ptr [ [[ARG1]], %[[BB0]] ] | ||
; CHECK-NEXT: [[I3_US:%.*]] = call i32 [[UNSWITCHED_SELECT_US]]() | ||
; CHECK-NEXT: br i1 true, label %[[LOOP_US]], label %[[RET_SPLIT_US:.*]] | ||
; CHECK: [[RET_SPLIT_US]]: | ||
; CHECK-NEXT: [[I3_LCSSA_US:%.*]] = phi i32 [ [[I3_US]], %[[BB1]] ] | ||
; CHECK-NEXT: br label %[[RET:.*]] | ||
; CHECK: [[START_SPLIT]]: | ||
; CHECK-NEXT: br label %[[LOOP:.*]] | ||
; CHECK: [[LOOP]]: | ||
; CHECK-NEXT: br label %[[BB2:.*]] | ||
; CHECK: [[BB2]]: | ||
; CHECK-NEXT: br i1 false, label %[[LOOP]], label %[[RET_SPLIT:.*]] | ||
; CHECK: [[RET_SPLIT]]: | ||
; CHECK-NEXT: [[I3_LE:%.*]] = call i32 @bar() | ||
; CHECK-NEXT: br label %[[RET]] | ||
; CHECK: [[RET]]: | ||
; CHECK-NEXT: [[DOTUS_PHI:%.*]] = phi i32 [ [[I3_LE]], %[[RET_SPLIT]] ], [ [[I3_LCSSA_US]], %[[RET_SPLIT_US]] ] | ||
; CHECK-NEXT: ret i32 [[DOTUS_PHI]] | ||
; | ||
start: | ||
br label %loop | ||
|
||
loop: ; preds = %loop, %bb | ||
%i = select i1 %arg, ptr %arg1, ptr @bar | ||
%i3 = call i32 %i() | ||
br i1 %arg, label %loop, label %ret | ||
|
||
ret: ; preds = %loop | ||
ret i32 %i3 | ||
} | ||
|
||
declare i32 @bar() nounwind willreturn memory(none) |