diff --git a/include/llvm/IR/Function.h b/include/llvm/IR/Function.h index cfb862d9b01..455469d1fa0 100644 --- a/include/llvm/IR/Function.h +++ b/include/llvm/IR/Function.h @@ -310,9 +310,16 @@ public: addAttribute(n, Attribute::NoCapture); } + bool doesNotAccessMemory(unsigned n) const { + return AttributeSets.hasAttribute(n, Attribute::ReadNone); + } + void setDoesNotAccessMemory(unsigned n) { + addAttribute(n, Attribute::ReadNone); + } + bool onlyReadsMemory(unsigned n) const { - return AttributeSets.hasAttribute(n, Attribute::ReadOnly) || - AttributeSets.hasAttribute(n, Attribute::ReadNone); + return doesNotAccessMemory(n) || + AttributeSets.hasAttribute(n, Attribute::ReadOnly); } void setOnlyReadsMemory(unsigned n) { addAttribute(n, Attribute::ReadOnly);