[llvm] c16fd6a - Rename doesNotReadMemory to onlyWritesMemory globally [NFC]
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 5 08:53:02 PST 2022
Author: Philip Reames
Date: 2022-01-05T08:52:55-08:00
New Revision: c16fd6a3762cce432319c1f0ea7aeff6666d9c26
URL: https://github.com/llvm/llvm-project/commit/c16fd6a3762cce432319c1f0ea7aeff6666d9c26
DIFF: https://github.com/llvm/llvm-project/commit/c16fd6a3762cce432319c1f0ea7aeff6666d9c26.diff
LOG: 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.
Added:
Modified:
llvm/include/llvm/Analysis/AliasAnalysis.h
llvm/include/llvm/IR/Function.h
llvm/include/llvm/IR/InstrTypes.h
llvm/lib/Analysis/AliasAnalysis.cpp
llvm/lib/Analysis/BasicAliasAnalysis.cpp
llvm/lib/IR/Instruction.cpp
llvm/lib/Transforms/IPO/FunctionAttrs.cpp
llvm/lib/Transforms/Scalar/LoopInterchange.cpp
llvm/lib/Transforms/Utils/BuildLibCalls.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/AliasAnalysis.h b/llvm/include/llvm/Analysis/AliasAnalysis.h
index 1ecbd4b830049..2dcdfa6bdde37 100644
--- a/llvm/include/llvm/Analysis/AliasAnalysis.h
+++ b/llvm/include/llvm/Analysis/AliasAnalysis.h
@@ -678,7 +678,7 @@ class AAResults {
/// 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));
}
diff --git a/llvm/include/llvm/IR/Function.h b/llvm/include/llvm/IR/Function.h
index 2c94897c61dce..90095cd1bc77c 100644
--- a/llvm/include/llvm/IR/Function.h
+++ b/llvm/include/llvm/IR/Function.h
@@ -509,10 +509,10 @@ class LLVM_EXTERNAL_VISIBILITY Function : public GlobalObject,
}
/// 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);
}
diff --git a/llvm/include/llvm/IR/InstrTypes.h b/llvm/include/llvm/IR/InstrTypes.h
index 3eedb762d1247..03839e00c7aab 100644
--- a/llvm/include/llvm/IR/InstrTypes.h
+++ b/llvm/include/llvm/IR/InstrTypes.h
@@ -1717,7 +1717,7 @@ class CallBase : public Instruction {
// 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 @@ class CallBase : public Instruction {
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.
diff --git a/llvm/lib/Analysis/AliasAnalysis.cpp b/llvm/lib/Analysis/AliasAnalysis.cpp
index 49199060786c2..5658499946556 100644
--- a/llvm/lib/Analysis/AliasAnalysis.cpp
+++ b/llvm/lib/Analysis/AliasAnalysis.cpp
@@ -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
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index 6f0da2cf18fab..fa9ccb095a21d 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -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;
}
diff --git a/llvm/lib/IR/Instruction.cpp b/llvm/lib/IR/Instruction.cpp
index 770fd8aa918be..59b7221d1fa2e 100644
--- a/llvm/lib/IR/Instruction.cpp
+++ b/llvm/lib/IR/Instruction.cpp
@@ -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();
}
diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
index bc3c3da447297..213a998d5bba2 100644
--- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -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);
diff --git a/llvm/lib/Transforms/Scalar/LoopInterchange.cpp b/llvm/lib/Transforms/Scalar/LoopInterchange.cpp
index 9f605b4ac4ad8..75b52a431e32c 100644
--- a/llvm/lib/Transforms/Scalar/LoopInterchange.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopInterchange.cpp
@@ -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 "
diff --git a/llvm/lib/Transforms/Utils/BuildLibCalls.cpp b/llvm/lib/Transforms/Utils/BuildLibCalls.cpp
index 0039bb68e7edf..8286d37e1f0eb 100644
--- a/llvm/lib/Transforms/Utils/BuildLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/BuildLibCalls.cpp
@@ -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:
More information about the llvm-commits
mailing list