[flang-commits] [flang] [flang][cuda] Avoid leaking managed descriptor created during code generation phase (PR #234851)

via flang-commits flang-commits at lists.llvm.org
Thu Oct 22 22:55:53 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions h,cpp -- flang/include/flang/Optimizer/CodeGen/CodeGen.h flang/lib/Optimizer/CodeGen/CodeGen.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/flang/lib/Optimizer/CodeGen/CodeGen.cpp b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
index d32091df8..732fcbca5 100644
--- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp
+++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
@@ -2392,12 +2392,10 @@ struct EmboxCommonConversion : public fir::FIROpConversion<OP> {
   /// If the embox is not in a globalOp body, allocate storage for the box;
   /// store the value inside and return the generated alloca. Return the input
   /// value otherwise.
-  mlir::Value
-  placeInMemoryIfNotGlobalInit(mlir::ConversionPatternRewriter &rewriter,
-                               mlir::Location loc, mlir::Type boxTy,
-                               mlir::Value boxValue,
-                               bool needDeviceAllocation = false,
-                               mlir::Value firBox = {}) const {
+  mlir::Value placeInMemoryIfNotGlobalInit(
+      mlir::ConversionPatternRewriter &rewriter, mlir::Location loc,
+      mlir::Type boxTy, mlir::Value boxValue, bool needDeviceAllocation = false,
+      mlir::Value firBox = {}) const {
     if (isInGlobalOp(rewriter))
       return boxValue;
     mlir::Type llvmBoxTy = boxValue.getType();
@@ -2469,9 +2467,9 @@ struct EmboxOpConversion : public EmboxCommonConversion<fir::EmboxOp> {
       return mlir::failure();
     }
     bool needsDeviceAlloc = isUsedByGPULaunchFunc(embox);
-    auto result = placeInMemoryIfNotGlobalInit(
-        rewriter, embox.getLoc(), boxTy, dest, needsDeviceAlloc,
-        embox.getResult());
+    auto result =
+        placeInMemoryIfNotGlobalInit(rewriter, embox.getLoc(), boxTy, dest,
+                                     needsDeviceAlloc, embox.getResult());
     rewriter.replaceOp(embox, result);
     return mlir::success();
   }
@@ -2873,9 +2871,9 @@ private:
     }
     dest = insertBaseAddress(rewriter, loc, dest, base);
     bool needsDeviceAlloc = isUsedByGPULaunchFunc(rebox);
-    mlir::Value result = placeInMemoryIfNotGlobalInit(
-        rewriter, rebox.getLoc(), destBoxTy, dest, needsDeviceAlloc,
-        rebox.getResult());
+    mlir::Value result =
+        placeInMemoryIfNotGlobalInit(rewriter, rebox.getLoc(), destBoxTy, dest,
+                                     needsDeviceAlloc, rebox.getResult());
     rewriter.replaceOp(rebox, result);
     return mlir::success();
   }

``````````

</details>


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


More information about the flang-commits mailing list