Skip to content

Commit

Permalink
[LLVMIR] Use helper methods to set/check readnone attribute (NFC)
Browse files Browse the repository at this point in the history
This makes the code forward-compatible to the memory attribute.
  • Loading branch information
nikic committed Oct 21, 2022
1 parent ec4db1d commit 87549e6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
Expand Up @@ -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());
}

Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
Expand Up @@ -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(
Expand Down

0 comments on commit 87549e6

Please sign in to comment.