[flang-commits] [PATCH] D141136: [flang] Allow and use fir.rebox in fir.global

Jean Perier via Phabricator via flang-commits flang-commits at lists.llvm.org
Mon Jan 9 01:33:01 PST 2023


jeanPerier updated this revision to Diff 487330.
jeanPerier added a comment.

Fix signed/unsigned narrowing warning.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141136/new/

https://reviews.llvm.org/D141136

Files:
  flang/lib/Optimizer/CodeGen/CodeGen.cpp


Index: flang/lib/Optimizer/CodeGen/CodeGen.cpp
===================================================================
--- flang/lib/Optimizer/CodeGen/CodeGen.cpp
+++ flang/lib/Optimizer/CodeGen/CodeGen.cpp
@@ -163,13 +163,11 @@
   mlir::Value getValueFromBox(mlir::Location loc, mlir::Value box,
                               mlir::Type resultTy,
                               mlir::ConversionPatternRewriter &rewriter,
-                              unsigned boxValue) const {
+                              int boxValue) const {
     if (box.getType().isa<mlir::LLVM::LLVMPointerType>()) {
       auto pty = mlir::LLVM::LLVMPointerType::get(resultTy);
       auto p = rewriter.create<mlir::LLVM::GEPOp>(
-          loc, pty, box,
-          llvm::ArrayRef<mlir::LLVM::GEPArg>{
-              0, static_cast<std::int32_t>(boxValue)});
+          loc, pty, box, llvm::ArrayRef<mlir::LLVM::GEPArg>{0, boxValue});
       return rewriter.create<mlir::LLVM::LoadOp>(loc, resultTy, p);
     }
     return rewriter.create<mlir::LLVM::ExtractValueOp>(loc, box, boxValue);
@@ -189,7 +187,7 @@
 
   llvm::SmallVector<mlir::Value, 3>
   getDimsFromBox(mlir::Location loc, llvm::ArrayRef<mlir::Type> retTys,
-                 mlir::Value box, unsigned dim,
+                 mlir::Value box, int dim,
                  mlir::ConversionPatternRewriter &rewriter) const {
     mlir::Value l0 = getDimFieldFromBox(loc, box, dim, 0, retTys[0], rewriter);
     mlir::Value l1 = getDimFieldFromBox(loc, box, dim, 1, retTys[1], rewriter);
@@ -205,19 +203,19 @@
            "descriptor inquiry with runtime dim can only be done on descriptor "
            "in memory");
     auto pty = mlir::LLVM::LLVMPointerType::get(ty);
-    mlir::LLVM::GEPOp p =
-        genGEP(loc, pty, rewriter, box, 0, kDimsPosInBox, dim, off);
+    mlir::LLVM::GEPOp p = genGEP(loc, pty, rewriter, box, 0,
+                                 static_cast<int>(kDimsPosInBox), dim, off);
     return rewriter.create<mlir::LLVM::LoadOp>(loc, ty, p);
   }
 
   mlir::Value
-  getDimFieldFromBox(mlir::Location loc, mlir::Value box, unsigned dim, int off,
+  getDimFieldFromBox(mlir::Location loc, mlir::Value box, int dim, int off,
                      mlir::Type ty,
                      mlir::ConversionPatternRewriter &rewriter) const {
     if (box.getType().isa<mlir::LLVM::LLVMPointerType>()) {
       auto pty = mlir::LLVM::LLVMPointerType::get(ty);
-      mlir::LLVM::GEPOp p =
-          genGEP(loc, pty, rewriter, box, 0, kDimsPosInBox, dim, off);
+      mlir::LLVM::GEPOp p = genGEP(loc, pty, rewriter, box, 0,
+                                   static_cast<int>(kDimsPosInBox), dim, off);
       return rewriter.create<mlir::LLVM::LoadOp>(loc, ty, p);
     }
     return rewriter.create<mlir::LLVM::ExtractValueOp>(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141136.487330.patch
Type: text/x-patch
Size: 2782 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230109/b33cbf00/attachment-0001.bin>


More information about the flang-commits mailing list