[PATCH] D17631: Make getModRefInfo more consistent for loads/stores and cmpxchg/atomicrmw

George Burgess IV via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 25 17:58:20 PST 2016


george.burgess.iv created this revision.
george.burgess.iv added a reviewer: eli.friedman.
george.burgess.iv added a subscriber: llvm-commits.

Hi!

When looking through lib/Analysis/AliasAnalysis.cpp, I noticed that we always answer conservatively for volatile loads/stores, but we don't necessarily do this for cmpxchg/atomicrmw. This seems inconsistent to me, so I'd like to know if it was intentional. If not, here's a patch to fix it. :)

The change is fairly insignificant/I can't get it to fire with a lit test, so no test is included. If we'd like one, I'm happy to see what I can do with gtest.

http://reviews.llvm.org/D17631

Files:
  lib/Analysis/AliasAnalysis.cpp

Index: lib/Analysis/AliasAnalysis.cpp
===================================================================
--- lib/Analysis/AliasAnalysis.cpp
+++ lib/Analysis/AliasAnalysis.cpp
@@ -276,7 +276,7 @@
 ModRefInfo AAResults::getModRefInfo(const AtomicCmpXchgInst *CX,
                                     const MemoryLocation &Loc) {
   // Acquire/Release cmpxchg has properties that matter for arbitrary addresses.
-  if (CX->getSuccessOrdering() > Monotonic)
+  if (CX->getSuccessOrdering() > Monotonic || CX->isVolatile())
     return MRI_ModRef;
 
   // If the cmpxchg address does not alias the location, it does not access it.
@@ -289,7 +289,7 @@
 ModRefInfo AAResults::getModRefInfo(const AtomicRMWInst *RMW,
                                     const MemoryLocation &Loc) {
   // Acquire/Release atomicrmw has properties that matter for arbitrary addresses.
-  if (RMW->getOrdering() > Monotonic)
+  if (RMW->getOrdering() > Monotonic || RMW->isVolatile())
     return MRI_ModRef;
 
   // If the atomicrmw address does not alias the location, it does not access it.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17631.49134.patch
Type: text/x-patch
Size: 1068 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160226/ce111317/attachment.bin>


More information about the llvm-commits mailing list