[flang-commits] [flang] [flang] Set common linkage to common block with zero initializer (PR #179548)
via flang-commits
flang-commits at lists.llvm.org
Tue Feb 3 13:01:46 PST 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 cpp -- 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 619ff61b7..faf722b55 100644
--- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp
+++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
@@ -3345,12 +3345,14 @@ struct GlobalOpConversion : public fir::FIROpConversion<fir::GlobalOp> {
rewriter.setInsertionPointAfter(insertOp);
rewriter.replaceOpWithNewOp<mlir::arith::ConstantOp>(
insertOp, seqTyAttr, denseAttr);
- if (auto intAttr = mlir::dyn_cast<mlir::IntegerAttr>(constant.getValue()))
+ if (auto intAttr =
+ mlir::dyn_cast<mlir::IntegerAttr>(constant.getValue()))
if (intAttr.getInt() == 0)
++nbZeroInitializers;
}
}
- if (nbRanges > 0 && nbRanges == nbZeroInitializers && linkage == mlir::LLVM::Linkage::External)
+ if (nbRanges > 0 && nbRanges == nbZeroInitializers &&
+ linkage == mlir::LLVM::Linkage::External)
g.setLinkage(mlir::LLVM::Linkage::Common);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/179548
More information about the flang-commits
mailing list