[llvm] [BOLT] Fix scavenge register after program point (PR #179207)

Haibo Jiang via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 2 03:06:04 PST 2026


https://github.com/Jianghibo created https://github.com/llvm/llvm-project/pull/179207

The dataflow direction of liveness analysis is backward, so the register state after ProgramPoint in the original instruction sequence must be obtained by calling getStateBefore() instead of getStateAt();

>From e0729400d56e93e5c00b57218720eb6f22268d2b Mon Sep 17 00:00:00 2001
From: jianghaibo <jianghaibo9 at huawei.com>
Date: Mon, 2 Feb 2026 18:59:43 +0800
Subject: [PATCH] [BOLT] Fix scavenge register after program point

The dataflow direction of liveness analysis is backward, so the register
state after ProgramPoint in the original instruction sequence must be
obtained by calling getStateBefore() instead of getStateAt();
---
 bolt/include/bolt/Passes/LivenessAnalysis.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bolt/include/bolt/Passes/LivenessAnalysis.h b/bolt/include/bolt/Passes/LivenessAnalysis.h
index f4faa1dc34ecd..ee982f3230b05 100644
--- a/bolt/include/bolt/Passes/LivenessAnalysis.h
+++ b/bolt/include/bolt/Passes/LivenessAnalysis.h
@@ -47,7 +47,7 @@ class LivenessAnalysis : public DataflowAnalysis<LivenessAnalysis, BitVector,
   // Return a usable general-purpose reg after point P. Return 0 if no reg is
   // available.
   MCPhysReg scavengeRegAfter(ProgramPoint P) {
-    BitVector BV = *this->getStateAt(P);
+    BitVector BV = *this->getStateBefore(P);
     BV.flip();
     BitVector GPRegs(NumRegs, false);
     this->BC.MIB->getGPRegs(GPRegs, /*IncludeAlias=*/false);



More information about the llvm-commits mailing list