[LLVMIR] Use helper methods to set/check readnone attribute (NFC)
authorNikita Popov <npopov@redhat.com>
Fri, 21 Oct 2022 14:22:26 +0000 (16:22 +0200)
committerNikita Popov <npopov@redhat.com>
Fri, 21 Oct 2022 14:23:52 +0000 (16:23 +0200)
This makes the code forward-compatible to the memory attribute.

mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

index 6ea7c71..2995ad3 100644 (file)
@@ -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());
 }
 
index 26bc99f..e409b66 100644 (file)
@@ -984,7 +984,7 @@ LogicalResult ModuleTranslation::convertFunctionSignatures() {
     addRuntimePreemptionSpecifier(function.getDsoLocal(), llvmFunc);
 
     if (function->getAttrOfType<UnitAttr>(LLVMDialect::getReadnoneAttrName()))
-      llvmFunc->addFnAttr(llvm::Attribute::ReadNone);
+      llvmFunc->setDoesNotAccessMemory();
 
     // Forward the pass-through attributes to LLVM.
     if (failed(forwardPassthroughAttributes(