[llvm] [BOLT][AArch64] Expand cmpbr when reversing would overflow (PR #202998)
Rafael Auler via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 4 18:33:33 PDT 2026
================
@@ -0,0 +1,56 @@
+//===- bolt/Passes/BranchLivenessUtils.cpp -------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "bolt/Passes/BranchLivenessUtils.h"
+#include "bolt/Core/BinaryContext.h"
+#include "bolt/Core/BinaryFunction.h"
+#include "bolt/Core/MCPlusBuilder.h"
+#include "bolt/Passes/DataflowInfoManager.h"
+#include "bolt/Passes/RegAnalysis.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/MC/MCRegister.h"
+
+namespace llvm {
+namespace bolt {
+
+bool needsBranchLiveness(BinaryFunction &BF) {
+ BinaryContext &BC = BF.getBinaryContext();
+ if (!BC.isAArch64())
+ return false;
+
+ return llvm::any_of(BF, [&](BinaryBasicBlock &BB) {
+ return llvm::any_of(
+ BB, [&](MCInst &Inst) { return BC.MIB->isShortRangeBranch(Inst); });
----------------
rafaelauler wrote:
overly broad, maybe ` isCompAndBranch(Inst) && !isReversibleBranch(Inst, /*MustPreserveFlags=*/true)` ?
https://github.com/llvm/llvm-project/pull/202998
More information about the llvm-commits
mailing list