================
@@ -3283,10 +3285,15 @@ static bool isAllocSiteRemovable(Instruction *AI,
           case Intrinsic::memcpy:
           case Intrinsic::memset: {
             MemIntrinsic *MI = cast<MemIntrinsic>(II);
-            if (MI->isVolatile() || MI->getRawDest() != PI)
+            if (MI->isVolatile())
               return false;
+            // Note: this could also be ModRef, but we can still interpret 
that as just Mod in that case.
+            ModRefInfo NewAccess = MI->getRawDest() == PI ? ModRefInfo::Mod : 
ModRefInfo::Ref;
+            if ((Access & ~NewAccess) != ModRefInfo::NoModRef)
+              return false;
----------------
nikic wrote:

> I originally was going to have it use AA to compute ModRef at the top, but 
> that seemed potentially slower (since we already know PI aliases).

Yeah, we shouldn't use AA here.

> I wasn't sure how else to centralize the test and also preserve exit early 
> unless I just duplicate it at the top and after the loop (`if (Access == 
> ModRefInfo::ModRef) return false`)?

Yeah, that's what I had in mind, but no strong opinion. We should probably at 
least assert that it's not ModRef after the loop though, to make sure no case 
was missed.

https://github.com/llvm/llvm-project/pull/143958
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to