[Mlir-commits] [mlir] a4ad79c - [MLIR] Remove some pointer element type accesses

Nikita Popov llvmlistbot at llvm.org
Fri Jan 28 00:51:00 PST 2022


Author: Nikita Popov
Date: 2022-01-28T09:50:52+01:00
New Revision: a4ad79c50a582664f8f87115c6a1a8d80252f6ec

URL: https://github.com/llvm/llvm-project/commit/a4ad79c50a582664f8f87115c6a1a8d80252f6ec
DIFF: https://github.com/llvm/llvm-project/commit/a4ad79c50a582664f8f87115c6a1a8d80252f6ec.diff

LOG: [MLIR] Remove some pointer element type accesses

Use the MLIR pointer element type, rather than the LLVM pointer
element type.

Added: 
    

Modified: 
    mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
index f347b2066760..75d04e164868 100644
--- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -767,21 +767,22 @@ LogicalResult ModuleTranslation::convertOneFunction(LLVMFuncOp func) {
     }
 
     if (auto attr = func.getArgAttrOfType<UnitAttr>(argIdx, "llvm.sret")) {
-      auto argTy = mlirArg.getType();
-      if (!argTy.isa<LLVM::LLVMPointerType>())
+      auto argTy = mlirArg.getType().dyn_cast<LLVM::LLVMPointerType>();
+      if (!argTy)
         return func.emitError(
             "llvm.sret attribute attached to LLVM non-pointer argument");
-      llvmArg.addAttrs(llvm::AttrBuilder(llvmArg.getContext()).addStructRetAttr(
-          llvmArg.getType()->getPointerElementType()));
+      llvmArg.addAttrs(
+          llvm::AttrBuilder(llvmArg.getContext())
+              .addStructRetAttr(convertType(argTy.getElementType())));
     }
 
     if (auto attr = func.getArgAttrOfType<UnitAttr>(argIdx, "llvm.byval")) {
-      auto argTy = mlirArg.getType();
-      if (!argTy.isa<LLVM::LLVMPointerType>())
+      auto argTy = mlirArg.getType().dyn_cast<LLVM::LLVMPointerType>();
+      if (!argTy)
         return func.emitError(
             "llvm.byval attribute attached to LLVM non-pointer argument");
-      llvmArg.addAttrs(llvm::AttrBuilder(llvmArg.getContext()).addByValAttr(
-          llvmArg.getType()->getPointerElementType()));
+      llvmArg.addAttrs(llvm::AttrBuilder(llvmArg.getContext())
+                           .addByValAttr(convertType(argTy.getElementType())));
     }
 
     mapValue(mlirArg, &llvmArg);


        


More information about the Mlir-commits mailing list