From 87549e61dae5c1cbb8ef590058aa93053ded481d Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 21 Oct 2022 16:22:26 +0200 Subject: [PATCH] [LLVMIR] Use helper methods to set/check readnone attribute (NFC) This makes the code forward-compatible to the memory attribute. --- mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp | 2 +- mlir/lib/Target/LLVMIR/ModuleTranslation.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp index 6ea7c71cd40d4..2995ad33e57fa 100644 --- a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp +++ b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp @@ -1018,7 +1018,7 @@ void Importer::processFunctionAttributes(llvm::Function *func, auto addNamedUnitAttr = [&](StringRef name) { return funcOp->setAttr(name, UnitAttr::get(context)); }; - if (func->hasFnAttribute(llvm::Attribute::ReadNone)) + if (func->doesNotAccessMemory()) addNamedUnitAttr(LLVMDialect::getReadnoneAttrName()); } diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp index 26bc99f53a568..e409b665c30d9 100644 --- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp @@ -984,7 +984,7 @@ LogicalResult ModuleTranslation::convertFunctionSignatures() { addRuntimePreemptionSpecifier(function.getDsoLocal(), llvmFunc); if (function->getAttrOfType(LLVMDialect::getReadnoneAttrName())) - llvmFunc->addFnAttr(llvm::Attribute::ReadNone); + llvmFunc->setDoesNotAccessMemory(); // Forward the pass-through attributes to LLVM. if (failed(forwardPassthroughAttributes(