[llvm] [LoopUnroll] Remove unused lifetime marker pairs (PR #106858)

via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 31 09:01:21 PDT 2024


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 140e80a220d751b289aca2cf993a96af9baa4063 f12d7f3efd2bd699880425e094cf07b414228c5e --extensions cpp -- llvm/lib/Transforms/Utils/LoopUnroll.cpp
``````````

</details>

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

``````````diff
diff --git a/llvm/lib/Transforms/Utils/LoopUnroll.cpp b/llvm/lib/Transforms/Utils/LoopUnroll.cpp
index 9e601215db..3ce83f8bb9 100644
--- a/llvm/lib/Transforms/Utils/LoopUnroll.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUnroll.cpp
@@ -377,9 +377,10 @@ void llvm::simplifyLoopAfterUnroll(Loop *L, bool SimplifyIVs, LoopInfo *LI,
   const DataLayout &DL = L->getHeader()->getDataLayout();
   Function *F = L->getHeader()->getParent();
   SmallVector<WeakTrackingVH, 16> DeadInsts;
-  bool DoNotOptimizeLifetimeMarkers = F->hasFnAttribute(Attribute::SanitizeAddress) ||
-        F->hasFnAttribute(Attribute::SanitizeMemory) ||
-        F->hasFnAttribute(Attribute::SanitizeHWAddress);
+  bool DoNotOptimizeLifetimeMarkers =
+      F->hasFnAttribute(Attribute::SanitizeAddress) ||
+      F->hasFnAttribute(Attribute::SanitizeMemory) ||
+      F->hasFnAttribute(Attribute::SanitizeHWAddress);
   for (BasicBlock *BB : L->getBlocks()) {
     // Remove repeated debug instructions after loop unrolling.
     if (BB->getParent()->getSubprogram())
@@ -392,19 +393,20 @@ void llvm::simplifyLoopAfterUnroll(Loop *L, bool SimplifyIVs, LoopInfo *LI,
       if (isInstructionTriviallyDead(&Inst))
         DeadInsts.emplace_back(&Inst);
       if (!DoNotOptimizeLifetimeMarkers)
-      if (auto *II = dyn_cast<IntrinsicInst>(&Inst)) {
-        if (II->getIntrinsicID() == Intrinsic::lifetime_start) {
-          if (auto *PrevII = dyn_cast_or_null<IntrinsicInst>(II->getPrevNode())) 
-            if (PrevII->getIntrinsicID() == Intrinsic::lifetime_end) {
-              if (PrevII->getArgOperand(0) == II->getArgOperand(0) && 
-                  PrevII->getArgOperand(1) == II->getArgOperand(1)) {
-                PrevII->eraseFromParent();
-                II->eraseFromParent();
-                continue;
+        if (auto *II = dyn_cast<IntrinsicInst>(&Inst)) {
+          if (II->getIntrinsicID() == Intrinsic::lifetime_start) {
+            if (auto *PrevII =
+                    dyn_cast_or_null<IntrinsicInst>(II->getPrevNode()))
+              if (PrevII->getIntrinsicID() == Intrinsic::lifetime_end) {
+                if (PrevII->getArgOperand(0) == II->getArgOperand(0) &&
+                    PrevII->getArgOperand(1) == II->getArgOperand(1)) {
+                  PrevII->eraseFromParent();
+                  II->eraseFromParent();
+                  continue;
+                }
               }
           }
         }
-      }
 
       // Fold ((add X, C1), C2) to (add X, C1+C2). This is very common in
       // unrolled loops, and handling this early allows following code to

``````````

</details>


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


More information about the llvm-commits mailing list