[llvm] [CGP] Do not eliminate blocks which have their address taken (PR #163962)

via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 17 07:16:22 PDT 2025


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/CodeGen/CodeGenPrepare.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/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 551dde26e..776dbda97 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -958,7 +958,8 @@ bool CodeGenPrepare::isMergingEmptyBlockProfitable(BasicBlock *BB,
   // This could lead to updates across functions which is problematic in a
   // function pass like codegenprepare. The update to a blockaddress in a
   // function defined before the function with the eliminated block is lost.
-  if(BB->hasAddressTaken()) return false;
+  if (BB->hasAddressTaken())
+    return false;
 
   // Do not delete loop preheaders if doing so would create a critical edge.
   // Loop preheaders can be good locations to spill registers. If the

``````````

</details>


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


More information about the llvm-commits mailing list