forked from OSchip/llvm-project
Rename doesNotReadMemory to onlyWritesMemory globally [NFC]
The naming has come up as a source of confusion in several recent reviews. onlyWritesMemory is consist with onlyReadsMemory which we use for the corresponding readonly case as well.
This commit is contained in:
parent
5730d11c2b
commit
c16fd6a376
|
@ -678,7 +678,7 @@ public:
|
|||
|
||||
/// Checks if functions with the specified behavior are known to only write
|
||||
/// memory (or not access memory at all).
|
||||
static bool doesNotReadMemory(FunctionModRefBehavior MRB) {
|
||||
static bool onlyWritesMemory(FunctionModRefBehavior MRB) {
|
||||
return !isRefSet(createModRefInfo(MRB));
|
||||
}
|
||||
|
||||
|
|
|
@ -509,10 +509,10 @@ public:
|
|||
}
|
||||
|
||||
/// Determine if the function does not access or only writes memory.
|
||||
bool doesNotReadMemory() const {
|
||||
bool onlyWritesMemory() const {
|
||||
return doesNotAccessMemory() || hasFnAttribute(Attribute::WriteOnly);
|
||||
}
|
||||
void setDoesNotReadMemory() {
|
||||
void setOnlyWritesMemory() {
|
||||
addFnAttr(Attribute::WriteOnly);
|
||||
}
|
||||
|
||||
|
|
|
@ -1717,7 +1717,7 @@ public:
|
|||
|
||||
// FIXME: Once this API is no longer duplicated in `CallSite`, rename this to
|
||||
// better indicate that this may return a conservative answer.
|
||||
bool doesNotReadMemory(unsigned OpNo) const {
|
||||
bool onlyWritesMemory(unsigned OpNo) const {
|
||||
return dataOperandHasImpliedAttr(OpNo, Attribute::WriteOnly) ||
|
||||
dataOperandHasImpliedAttr(OpNo, Attribute::ReadNone);
|
||||
}
|
||||
|
@ -1824,10 +1824,10 @@ public:
|
|||
void setOnlyReadsMemory() { addFnAttr(Attribute::ReadOnly); }
|
||||
|
||||
/// Determine if the call does not access or only writes memory.
|
||||
bool doesNotReadMemory() const {
|
||||
bool onlyWritesMemory() const {
|
||||
return doesNotAccessMemory() || hasFnAttr(Attribute::WriteOnly);
|
||||
}
|
||||
void setDoesNotReadMemory() { addFnAttr(Attribute::WriteOnly); }
|
||||
void setOnlyWritesMemory() { addFnAttr(Attribute::WriteOnly); }
|
||||
|
||||
/// Determine if the call can access memmory only using pointers based
|
||||
/// on its arguments.
|
||||
|
|
|
@ -242,7 +242,7 @@ ModRefInfo AAResults::getModRefInfo(const CallBase *Call,
|
|||
|
||||
if (onlyReadsMemory(MRB))
|
||||
Result = clearMod(Result);
|
||||
else if (doesNotReadMemory(MRB))
|
||||
else if (onlyWritesMemory(MRB))
|
||||
Result = clearRef(Result);
|
||||
|
||||
if (onlyAccessesArgPointees(MRB) || onlyAccessesInaccessibleOrArgMem(MRB)) {
|
||||
|
@ -320,7 +320,7 @@ ModRefInfo AAResults::getModRefInfo(const CallBase *Call1,
|
|||
// from Call1 reading memory written by Call2.
|
||||
if (onlyReadsMemory(Call1B))
|
||||
Result = clearMod(Result);
|
||||
else if (doesNotReadMemory(Call1B))
|
||||
else if (onlyWritesMemory(Call1B))
|
||||
Result = clearRef(Result);
|
||||
|
||||
// If Call2 only access memory through arguments, accumulate the mod/ref
|
||||
|
|
|
@ -779,7 +779,7 @@ FunctionModRefBehavior BasicAAResult::getModRefBehavior(const CallBase *Call) {
|
|||
// than that.
|
||||
if (Call->onlyReadsMemory())
|
||||
Min = FMRB_OnlyReadsMemory;
|
||||
else if (Call->doesNotReadMemory())
|
||||
else if (Call->onlyWritesMemory())
|
||||
Min = FMRB_OnlyWritesMemory;
|
||||
|
||||
if (Call->onlyAccessesArgMemory())
|
||||
|
@ -812,7 +812,7 @@ FunctionModRefBehavior BasicAAResult::getModRefBehavior(const Function *F) {
|
|||
// If the function declares it only reads memory, go with that.
|
||||
if (F->onlyReadsMemory())
|
||||
Min = FMRB_OnlyReadsMemory;
|
||||
else if (F->doesNotReadMemory())
|
||||
else if (F->onlyWritesMemory())
|
||||
Min = FMRB_OnlyWritesMemory;
|
||||
|
||||
if (F->onlyAccessesArgMemory())
|
||||
|
@ -972,7 +972,7 @@ ModRefInfo BasicAAResult::getModRefInfo(const CallBase *Call,
|
|||
continue;
|
||||
}
|
||||
// Operand aliases 'Object' but call only writes into it.
|
||||
if (Call->doesNotReadMemory(OperandNo)) {
|
||||
if (Call->onlyWritesMemory(OperandNo)) {
|
||||
Result = setMod(Result);
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -585,7 +585,7 @@ bool Instruction::mayReadFromMemory() const {
|
|||
case Instruction::Call:
|
||||
case Instruction::Invoke:
|
||||
case Instruction::CallBr:
|
||||
return !cast<CallBase>(this)->doesNotReadMemory();
|
||||
return !cast<CallBase>(this)->onlyWritesMemory();
|
||||
case Instruction::Store:
|
||||
return !cast<StoreInst>(this)->isUnordered();
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ static MemoryAccessKind checkFunctionMemoryAccess(Function &F, bool ThisBody,
|
|||
if (AliasAnalysis::onlyReadsMemory(MRB))
|
||||
return MAK_ReadOnly;
|
||||
|
||||
if (AliasAnalysis::doesNotReadMemory(MRB))
|
||||
if (AliasAnalysis::onlyWritesMemory(MRB))
|
||||
return MAK_WriteOnly;
|
||||
|
||||
// Conservatively assume it reads and writes to memory.
|
||||
|
@ -295,7 +295,7 @@ static void addReadAttrs(const SCCNodeSet &SCCNodes, AARGetterT &&AARGetter,
|
|||
// No change.
|
||||
continue;
|
||||
|
||||
if (F->doesNotReadMemory() && WritesMemory)
|
||||
if (F->onlyWritesMemory() && WritesMemory)
|
||||
continue;
|
||||
|
||||
Changed.insert(F);
|
||||
|
|
|
@ -1076,7 +1076,7 @@ bool LoopInterchangeLegality::canInterchangeLoops(unsigned InnerLoopId,
|
|||
for (Instruction &I : BB->instructionsWithoutDebug())
|
||||
if (CallInst *CI = dyn_cast<CallInst>(&I)) {
|
||||
// readnone functions do not prevent interchanging.
|
||||
if (CI->doesNotReadMemory())
|
||||
if (CI->onlyWritesMemory())
|
||||
continue;
|
||||
LLVM_DEBUG(
|
||||
dbgs() << "Loops with call instructions cannot be interchanged "
|
||||
|
|
|
@ -72,8 +72,8 @@ static bool setOnlyReadsMemory(Function &F) {
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool setDoesNotReadMemory(Function &F) {
|
||||
if (F.doesNotReadMemory()) // writeonly or readnone
|
||||
static bool setOnlyWritesMemory(Function &F) {
|
||||
if (F.onlyWritesMemory()) // writeonly or readnone
|
||||
return false;
|
||||
// Turn readonly and writeonly into readnone.
|
||||
if (F.hasFnAttribute(Attribute::ReadOnly)) {
|
||||
|
@ -81,7 +81,7 @@ static bool setDoesNotReadMemory(Function &F) {
|
|||
return setDoesNotAccessMemory(F);
|
||||
}
|
||||
++NumWriteOnly;
|
||||
F.setDoesNotReadMemory();
|
||||
F.setOnlyWritesMemory();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1185,7 +1185,7 @@ bool llvm::inferLibFuncAttributes(Function &F, const TargetLibraryInfo &TLI) {
|
|||
case LibFunc_truncl:
|
||||
Changed |= setDoesNotThrow(F);
|
||||
Changed |= setDoesNotFreeMemory(F);
|
||||
Changed |= setDoesNotReadMemory(F);
|
||||
Changed |= setOnlyWritesMemory(F);
|
||||
Changed |= setWillReturn(F);
|
||||
return Changed;
|
||||
default:
|
||||
|
|
Loading…
Reference in New Issue