[llvm] dab1e30 - [SimplifyCFG][NFC] Renumber blocks when changing func (#186666)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 15 08:45:06 PDT 2026
Author: Alexis Engelke
Date: 2026-03-15T16:45:01+01:00
New Revision: dab1e30d39fec6c17e0e5a8dd1d2a3dbb2a9aa96
URL: https://github.com/llvm/llvm-project/commit/dab1e30d39fec6c17e0e5a8dd1d2a3dbb2a9aa96
DIFF: https://github.com/llvm/llvm-project/commit/dab1e30d39fec6c17e0e5a8dd1d2a3dbb2a9aa96.diff
LOG: [SimplifyCFG][NFC] Renumber blocks when changing func (#186666)
Keep numbering dense when changing the function. SimplifyCFG is a good
candidate, because it is likely to remove blocks and preserves few
analyses.
Added:
Modified:
llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp b/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
index e790ab8ac1df5..debf033c70c41 100644
--- a/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
+++ b/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
@@ -380,9 +380,13 @@ PreservedAnalyses SimplifyCFGPass::run(Function &F,
DT = &AM.getResult<DominatorTreeAnalysis>(F);
if (!simplifyFunctionCFG(F, TTI, DT, Options))
return PreservedAnalyses::all();
+ // If we removed some blocks, update block numbers to keep dense numbering.
+ F.renumberBlocks();
PreservedAnalyses PA;
- if (RequireAndPreserveDomTree)
+ if (RequireAndPreserveDomTree) {
+ DT->updateBlockNumbers();
PA.preserve<DominatorTreeAnalysis>();
+ }
return PA;
}
More information about the llvm-commits
mailing list