[PATCH] D88782: [MemorySSA] Consistently handle lifetime.start clobbers
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 3 08:35:08 PDT 2020
nikic created this revision.
nikic added reviewers: asbirlea, fhahn.
Herald added subscribers: llvm-commits, george.burgess.iv, hiraditya, Prazek.
Herald added a project: LLVM.
nikic requested review of this revision.
Currently lifetime.start clobbers are only considered if the UseInstruction is not a call, which doesn't really make sense to me. In particular, this means that asking for the clobber of a lifetime.start intrinsic at the memory location of that intrinsic will *not* return the intrinsic itself. (This introduces a difference between calling getClobberingMemoryAccess() without location, and calling it on the defining access with a location.)
I'm fixing this by removing the explicit lifetime.start handling from the switch -- as far as I can see, the generic code will handle this correctly already.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D88782
Files:
llvm/lib/Analysis/MemorySSA.cpp
llvm/unittests/Analysis/MemorySSATest.cpp
Index: llvm/unittests/Analysis/MemorySSATest.cpp
===================================================================
--- llvm/unittests/Analysis/MemorySSATest.cpp
+++ llvm/unittests/Analysis/MemorySSATest.cpp
@@ -1205,8 +1205,8 @@
// %bar = getelementptr i8, i8* %foo, i64 1
// store i8 0, i8* %foo
// store i8 0, i8* %bar
- // call void @llvm.lifetime.end.p0i8(i64 8, i32* %p)
- // call void @llvm.lifetime.start.p0i8(i64 8, i32* %p)
+ // call void @llvm.lifetime.end.p0i8(i64 8, i32* %foo)
+ // call void @llvm.lifetime.start.p0i8(i64 8, i32* %foo)
// store i8 0, i8* %foo
// store i8 0, i8* %bar
// ret void
@@ -1263,6 +1263,11 @@
MemoryAccess *BarClobber =
MSSA.getWalker()->getClobberingMemoryAccess(BarAccess);
EXPECT_EQ(BarClobber, LifetimeStartAccess);
+
+ MemoryAccess *LifetimeStartClobber =
+ MSSA.getWalker()->getClobberingMemoryAccess(
+ LifetimeStartAccess, MemoryLocation(Foo));
+ EXPECT_EQ(LifetimeStartClobber, LifetimeStartAccess);
}
TEST_F(MemorySSATest, DefOptimizationsAreInvalidatedOnMoving) {
Index: llvm/lib/Analysis/MemorySSA.cpp
===================================================================
--- llvm/lib/Analysis/MemorySSA.cpp
+++ llvm/lib/Analysis/MemorySSA.cpp
@@ -276,11 +276,6 @@
// clobbers where they don't really exist at all. Please see D43269 for
// context.
switch (II->getIntrinsicID()) {
- case Intrinsic::lifetime_start:
- if (UseCall)
- return {false, NoAlias};
- AR = AA.alias(MemoryLocation(II->getArgOperand(1)), UseLoc);
- return {AR != NoAlias, AR};
case Intrinsic::lifetime_end:
case Intrinsic::invariant_start:
case Intrinsic::invariant_end:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88782.295979.patch
Type: text/x-patch
Size: 1725 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201003/5926297b/attachment.bin>
More information about the llvm-commits
mailing list