Modify ModRefInfo values using static inline method abstractions [NFC].

Summary:
The aim is to make ModRefInfo checks and changes more intuitive
and less error prone using inline methods that abstract the bit operations.

Ideally ModRefInfo would become an enum class, but that change will require
a wider set of changes into FunctionModRefBehavior.

Reviewers: sanjoy, george.burgess.iv, dberlin, hfinkel

Subscribers: nlopes, llvm-commits

Differential Revision: https://reviews.llvm.org/D40749

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319821 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Alina Sbirlea
2017-12-05 20:12:23 +00:00
parent b7cbf75ecd
commit a2d30e9740
16 changed files with 171 additions and 125 deletions
+9 -7
View File
@@ -809,12 +809,12 @@ ModRefInfo BasicAAResult::getModRefInfo(ImmutableCallSite CS,
// Operand aliases 'Object', but call doesn't modify it. Strengthen
// initial assumption and keep looking in case if there are more aliases.
if (CS.onlyReadsMemory(OperandNo)) {
Result = static_cast<ModRefInfo>(Result | MRI_Ref);
Result = setRef(Result);
continue;
}
// Operand aliases 'Object' but call only writes into it.
if (CS.doesNotReadMemory(OperandNo)) {
Result = static_cast<ModRefInfo>(Result | MRI_Mod);
Result = setMod(Result);
continue;
}
// This operand aliases 'Object' and call reads and writes into it.
@@ -832,7 +832,7 @@ ModRefInfo BasicAAResult::getModRefInfo(ImmutableCallSite CS,
// routines do not read values visible in the IR. TODO: Consider special
// casing realloc and strdup routines which access only their arguments as
// well. Or alternatively, replace all of this with inaccessiblememonly once
// that's implemented fully.
// that's implemented fully.
auto *Inst = CS.getInstruction();
if (isMallocOrCallocLikeFn(Inst, &TLI)) {
// Be conservative if the accessed pointer may alias the allocation -
@@ -860,9 +860,9 @@ ModRefInfo BasicAAResult::getModRefInfo(ImmutableCallSite CS,
// It's also possible for Loc to alias both src and dest, or neither.
ModRefInfo rv = MRI_NoModRef;
if (SrcAA != NoAlias)
rv = static_cast<ModRefInfo>(rv | MRI_Ref);
rv = setRef(rv);
if (DestAA != NoAlias)
rv = static_cast<ModRefInfo>(rv | MRI_Mod);
rv = setMod(rv);
return rv;
}
@@ -933,10 +933,12 @@ ModRefInfo BasicAAResult::getModRefInfo(ImmutableCallSite CS1,
// possibilities for guard intrinsics.
if (isIntrinsicCall(CS1, Intrinsic::experimental_guard))
return getModRefBehavior(CS2) & MRI_Mod ? MRI_Ref : MRI_NoModRef;
return isModSet(ModRefInfo(getModRefBehavior(CS2))) ? MRI_Ref
: MRI_NoModRef;
if (isIntrinsicCall(CS2, Intrinsic::experimental_guard))
return getModRefBehavior(CS1) & MRI_Mod ? MRI_Mod : MRI_NoModRef;
return isModSet(ModRefInfo(getModRefBehavior(CS1))) ? MRI_Mod
: MRI_NoModRef;
// The AAResultBase base class has some smarts, lets use them.
return AAResultBase::getModRefInfo(CS1, CS2);