[DSE.MSSA] Only use callCapturesBefore for calls.
authorFlorian Hahn <flo@fhahn.com>
Wed, 8 Apr 2020 13:22:43 +0000 (14:22 +0100)
committerFlorian Hahn <flo@fhahn.com>
Wed, 8 Apr 2020 14:12:33 +0000 (15:12 +0100)
callCapturesBefore always returns ModRef , if UseInst isn't a call. As
we only call it if we already know Mod is set, this only destroys the
Must bit for non-calls.

llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp

index bccfefa..7b0a877 100644 (file)
@@ -1575,12 +1575,13 @@ struct DSEState {
 
     ModRefInfo MR = AA.getModRefInfo(UseInst, DefLoc);
     // If necessary, perform additional analysis.
-    if (isModSet(MR))
+    if (isModSet(MR) && isa<CallBase>(UseInst))
       MR = AA.callCapturesBefore(UseInst, DefLoc, &DT);
 
     Optional<MemoryLocation> UseLoc = getLocForWriteEx(UseInst);
     return isModSet(MR) && isMustSet(MR) &&
-           UseLoc->Size.getValue() >= DefLoc.Size.getValue();
+           (UseLoc->Size.hasValue() && DefLoc.Size.hasValue() &&
+            UseLoc->Size.getValue() >= DefLoc.Size.getValue());
   }
 
   /// Returns true if \p Use may read from \p DefLoc.