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

Christian Ulmann llvmlistbot at llvm.org
Mon Jul 22 02:19:24 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();
+    // Only set the attr when it does not match the default value.
+    auto othermem = convertModRefInfoFromLLVM(
+        memEffects.getModRef(llvm::MemoryEffects::Location::Other));
+    auto argMem = convertModRefInfoFromLLVM(
+        memEffects.getModRef(llvm::MemoryEffects::Location::ArgMem));
+    auto inaccessibleMem = convertModRefInfoFromLLVM(
+        memEffects.getModRef(llvm::MemoryEffects::Location::InaccessibleMem));
+    auto memAttr = MemoryEffectsAttr::get(callOp.getContext(), othermem, argMem,
+                                          inaccessibleMem);
+    if (!memAttr.isReadWrite()) {
+      callOp.setMemoryAttr(memAttr);
+    }
----------------
Dinistro wrote:

```suggestion
    auto othermem = convertModRefInfoFromLLVM(
        memEffects.getModRef(llvm::MemoryEffects::Location::Other));
    auto argMem = convertModRefInfoFromLLVM(
        memEffects.getModRef(llvm::MemoryEffects::Location::ArgMem));
    auto 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);
```

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


More information about the Mlir-commits mailing list