-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[LICM] allow MemoryAccess creation failure #116813
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
b2eb1f4
b164143
6b80bdb
5d2867b
e6b291a
e553a41
de04782
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1678,7 +1678,7 @@ deleteDeadClonedBlocks(Loop &L, ArrayRef<BasicBlock *> ExitBlocks, | |
| if (BasicBlock *ClonedBB = cast_or_null<BasicBlock>(VMap->lookup(BB))) | ||
| if (!DT.isReachableFromEntry(ClonedBB)) { | ||
| for (BasicBlock *SuccBB : successors(ClonedBB)) | ||
| SuccBB->removePredecessor(ClonedBB); | ||
| SuccBB->removePredecessor(ClonedBB, /*KeepOneInputPHIs*/ true); | ||
| DeadBlocks.push_back(ClonedBB); | ||
| } | ||
|
|
||
|
|
@@ -1716,7 +1716,7 @@ static void deleteDeadBlocksFromLoop(Loop &L, | |
| auto *BB = DeathCandidates.pop_back_val(); | ||
| if (!DeadBlockSet.count(BB) && !DT.isReachableFromEntry(BB)) { | ||
| for (BasicBlock *SuccBB : successors(BB)) { | ||
| SuccBB->removePredecessor(BB); | ||
| SuccBB->removePredecessor(BB, /*KeepOneInputPHIs*/ true); | ||
| DeathCandidates.push_back(SuccBB); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question: why can't MemorySSA be updated here? Is it because |
||
| } | ||
| DeadBlockSet.insert(BB); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| ; RUN: opt -passes='loop-mssa(simple-loop-unswitch<nontrivial>),print<memoryssa>' -verify-memoryssa -disable-output -S < %s 2>&1 | FileCheck %s | ||
| ; RUN: opt -passes='loop-mssa(simple-loop-unswitch<nontrivial>,licm)' -verify-memoryssa -disable-output -S | ||
|
||
|
|
||
| ; Check that SimpleLoopUnswitch preserves the MemoryDef of `call i32 @bar()` by preserving the PHI node. | ||
| ; Also, check that executing LICM after SimpleLoopUnswitch does not result in a crash. | ||
|
|
||
| ; CHECK: %unswitched.select = phi ptr [ @bar, %bb2 ] | ||
| ; CHECK-NEXT: MemoryDef | ||
|
||
| ; CHECK-NEXT: call i32 %unswitched.select() | ||
|
|
||
| define i32 @foo(i1 %arg, ptr %arg1) { | ||
| bb: | ||
| br label %bb2 | ||
|
|
||
| bb2: ; preds = %bb2, %bb | ||
| %i = select i1 %arg, ptr %arg1, ptr @bar | ||
| %i3 = call i32 %i() | ||
| br i1 %arg, label %bb2, label %bb4 | ||
|
|
||
| bb4: ; preds = %bb2 | ||
| ret i32 %i3 | ||
| } | ||
|
|
||
| declare i32 @bar() nounwind willreturn memory(none) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a test case for now yet, but I think we also need to keep one phi here.