[llvm] [SROA] Only canonicalize arrays when promotion is guaranteed (PR #219557)

via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 28 11:48:31 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 cpp -- llvm/lib/Transforms/Scalar/SROA.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/llvm/lib/Transforms/Scalar/SROA.cpp b/llvm/lib/Transforms/Scalar/SROA.cpp
index b312d52f1..5b155d066 100644
--- a/llvm/lib/Transforms/Scalar/SROA.cpp
+++ b/llvm/lib/Transforms/Scalar/SROA.cpp
@@ -4816,7 +4816,7 @@ static bool containsNonIntegralPointer(Type *Ty, const DataLayout &DL) {
 /// Return true if every non-ignorable use covers the whole partition and can
 /// be rewritten as a direct access to NewTy.
 static bool areAllUsesWholePartitionPromotable(Partition &P, Type *NewTy,
-                                                const DataLayout &DL) {
+                                               const DataLayout &DL) {
   auto IsPromotable = [&](const Slice &S) {
     if (S.isDead() || !S.getUse())
       return true;
@@ -4826,12 +4826,11 @@ static bool areAllUsesWholePartitionPromotable(Partition &P, Type *NewTy,
         II && (II->isLifetimeStartOrEnd() || II->isDroppable()))
       return true;
 
-    if (S.beginOffset() > P.beginOffset() ||
-        S.endOffset() < P.endOffset())
+    if (S.beginOffset() > P.beginOffset() || S.endOffset() < P.endOffset())
       return false;
 
-    bool IsExactPartition = S.beginOffset() == P.beginOffset() &&
-                            S.endOffset() == P.endOffset();
+    bool IsExactPartition =
+        S.beginOffset() == P.beginOffset() && S.endOffset() == P.endOffset();
     if (auto *LI = dyn_cast<LoadInst>(Usr)) {
       if (LI->isVolatile())
         return false;

``````````

</details>


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


More information about the llvm-commits mailing list