diff --git a/llvm/include/llvm/Analysis/AliasAnalysis.h b/llvm/include/llvm/Analysis/AliasAnalysis.h index 1ecbd4b8300491..2dcdfa6bdde373 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 2c94897c61dce3..90095cd1bc77c7 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 3eedb762d12476..03839e00c7aab8 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 49199060786c22..56584999465566 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 6f0da2cf18fab4..fa9ccb095a21de 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 770fd8aa918bef..59b7221d1fa2ef 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(this)->doesNotReadMemory(); + return !cast(this)->onlyWritesMemory(); case Instruction::Store: return !cast(this)->isUnordered(); } diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp index bc3c3da4472972..213a998d5bba24 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 9f605b4ac4ad8c..75b52a431e32c4 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(&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 0039bb68e7edfb..8286d37e1f0eb6 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: