-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[InterleavedAccessPass]: Ensure that dead nodes get erased only once #122643
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
Conversation
@llvm/pr-subscribers-llvm-transforms Author: Hassnaa Hamdi (hassnaaHamdi) ChangesFull diff: https://github.com/llvm/llvm-project/pull/122643.diff 2 Files Affected:
diff --git a/llvm/lib/CodeGen/InterleavedAccessPass.cpp b/llvm/lib/CodeGen/InterleavedAccessPass.cpp
index 8b6e3180986c30..a197e1c7e4b202 100644
--- a/llvm/lib/CodeGen/InterleavedAccessPass.cpp
+++ b/llvm/lib/CodeGen/InterleavedAccessPass.cpp
@@ -545,7 +545,8 @@ bool InterleavedAccessImpl::runOnFunction(Function &F) {
}
for (auto *I : DeadInsts)
- I->eraseFromParent();
+ if (I->getParent())
+ I->eraseFromParent();
return Changed;
}
diff --git a/llvm/test/Transforms/InterleavedAccess/AArch64/sve-interleave4.ll b/llvm/test/Transforms/InterleavedAccess/AArch64/sve-interleave4.ll
index e8d113ae3763d7..085089978d8f51 100644
--- a/llvm/test/Transforms/InterleavedAccess/AArch64/sve-interleave4.ll
+++ b/llvm/test/Transforms/InterleavedAccess/AArch64/sve-interleave4.ll
@@ -55,3 +55,17 @@ define void @mix_interleave4_interleave2(ptr %dst1, ptr %dst2, <vscale x 4 x i32
store <vscale x 8 x i32> %interleaved, ptr %dst2, align 4
ret void
}
+
+; This case tests when the interleave is using same parameter twice,
+; the dead parameter will not get deleted twice.
+define void @duplicate_by_interleave(<vscale x 4 x i32> %A, <vscale x 4 x i32> %B, ptr writeonly %AB_duplicate) {
+; CHECK-LABEL: define void @duplicate_by_interleave
+; CHECK-SAME: (<vscale x 4 x i32> [[A:%.*]], <vscale x 4 x i32> [[B:%.*]], ptr writeonly [[AB_DUPLICATE:%.*]]) #[[ATTR0]] {
+; CHECK-NEXT: call void @llvm.aarch64.sve.st4.nxv4i32(<vscale x 4 x i32> [[A]], <vscale x 4 x i32> [[A]], <vscale x 4 x i32> [[B]], <vscale x 4 x i32> [[B]], <vscale x 4 x i1> splat (i1 true), ptr [[AB_DUPLICATE]])
+; CHECK-NEXT: ret void
+;
+ %interleave = tail call <vscale x 8 x i32> @llvm.vector.interleave2.nxv8i32(<vscale x 4 x i32> %A, <vscale x 4 x i32> %B)
+ %duplicate_by_interleave = tail call <vscale x 16 x i32> @llvm.vector.interleave2.nxv16i32(<vscale x 8 x i32> %interleave, <vscale x 8 x i32> %interleave)
+ store <vscale x 16 x i32> %duplicate_by_interleave, ptr %AB_duplicate, align 4
+ ret void
+}
|
@@ -545,7 +545,8 @@ bool InterleavedAccessImpl::runOnFunction(Function &F) { | |||
} | |||
|
|||
for (auto *I : DeadInsts) | |||
I->eraseFromParent(); | |||
if (I->getParent()) |
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.
It looks like you're trying to fix a scenario where the same Instruction is included twice in DeadInsts
, right? I think the problem here is that I
may have been deleted and so you're dereferencing unreliable contents in memory or we could seg fault. I think you probably need to fix this a different way either by:
- Keeping track of which instructions you've deleted, i.e. by maintaining a map of visited instructions. Or,
- Removing duplicate dead instructions from the list before iterating over them.
Could it use SmallSetVector to store the Dead instructions? It should rule out any duplicated whilst keeping them in order, so that they are removed in the correct order. |
I thought about this, but I found that there will be changes in other functions also. |
Use SmallSetVector instead of SmallVector to avoid duplication, so that dead nodes get erased/deleted only once.
3488632
to
191f472
Compare
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.
LGTM
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/16/builds/11951 Here is the relevant piece of the build log for the reference
|
Use SmallSetVector instead of SmallVector to avoid duplication,
so that dead nodes get erased/deleted only once.