[Mlir-commits] [mlir] [mlir] Added new attributes to the llvm.call op in llvmir target (PR #99663)

Tobias Gysi llvmlistbot at llvm.org
Mon Jul 22 09:05:17 PDT 2024


================
@@ -1471,6 +1471,30 @@ LogicalResult ModuleImport::convertInstruction(llvm::Instruction *inst) {
     callOp.setTailCallKind(
         convertTailCallKindFromLLVM(callInst->getTailCallKind()));
     setFastmathFlagsAttr(inst, callOp);
+
+    // handle function attrs
+    if (callInst->hasFnAttr(llvm::Attribute::Convergent))
+      callOp.setConvergent(true);
+    if (callInst->hasFnAttr(llvm::Attribute::NoUnwind))
+      callOp.setNoUnwind(true);
+    if (callInst->hasFnAttr(llvm::Attribute::WillReturn))
+      callOp.setWillReturn(true);
+
+    // memory effects
+    llvm::MemoryEffects memEffects = callInst->getMemoryEffects();
+    ModRefInfo othermem = convertModRefInfoFromLLVM(
+        memEffects.getModRef(llvm::MemoryEffects::Location::Other));
+    ModRefInfo argMem = convertModRefInfoFromLLVM(
+        memEffects.getModRef(llvm::MemoryEffects::Location::ArgMem));
+    ModRefInfo inaccessibleMem = convertModRefInfoFromLLVM(
+        memEffects.getModRef(llvm::MemoryEffects::Location::InaccessibleMem));
+    auto memAttr = MemoryEffectsAttr::get(callOp.getContext(), othermem, argMem,
+                                          inaccessibleMem);
+    // Only set the attr when it does not match the default value.
+    if (!memAttr.isReadWrite()) {
+      callOp.setMemoryAttr(memAttr);
+    }
----------------
gysit wrote:

```suggestion
    if (!memAttr.isReadWrite()) 
      callOp.setMemoryAttr(memAttr);
```
nit:

https://github.com/llvm/llvm-project/pull/99663


More information about the Mlir-commits mailing list