[llvm] r321309 - [ModRefInfo] Add must alias info to ModRefInfo.
Nuno Lopes via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 22 08:10:59 PST 2017
Hi Alina,
Some comments below; I think some operations cannot be marked as MustModRef:
> @@ -440,9 +479,17 @@ ModRefInfo AAResults::getModRefInfo(cons
> if (isStrongerThanMonotonic(CX->getSuccessOrdering()))
> return ModRefInfo::ModRef;
>
> - // If the cmpxchg address does not alias the location, it does not
> access it.
> - if (Loc.Ptr && !alias(MemoryLocation::get(CX), Loc))
> - return ModRefInfo::NoModRef;
> + if (Loc.Ptr) {
> + AliasResult AR = alias(MemoryLocation::get(CX), Loc);
> + // If the cmpxchg address does not alias the location, it does not
> access
> + // it.
> + if (AR == NoAlias)
> + return ModRefInfo::NoModRef;
> +
> + // If the cmpxchg address aliases the pointer as must alias, set
> Must.
> + if (AR == MustAlias)
> + return ModRefInfo::MustModRef;
> + }
According to the manual (http://llvm.org/docs/LangRef.html#id205), cmpxchg
may or may not write to the location, depending on whether the comparison
succeeds. For weak operations, the write may not occur even if the
comparison succeeds.
> @@ -453,9 +500,17 @@ ModRefInfo AAResults::getModRefInfo(cons
> if (isStrongerThanMonotonic(RMW->getOrdering()))
> return ModRefInfo::ModRef;
>
> - // If the atomicrmw address does not alias the location, it does not
> access it.
> - if (Loc.Ptr && !alias(MemoryLocation::get(RMW), Loc))
> - return ModRefInfo::NoModRef;
> + if (Loc.Ptr) {
> + AliasResult AR = alias(MemoryLocation::get(RMW), Loc);
> + // If the atomicrmw address does not alias the location, it does not
> access
> + // it.
> + if (AR == NoAlias)
> + return ModRefInfo::NoModRef;
> +
> + // If the atomicrmw address aliases the pointer as must alias, set
> Must.
> + if (AR == MustAlias)
> + return ModRefInfo::MustModRef;
> + }
>
According to the manual (http://llvm.org/docs/LangRef.html#id210) not all
'atomicrmw' operations read the pointer. The instruction always writes, but
may not read (depending on the underlying operation).
Nuno
More information about the llvm-commits
mailing list