[llvm] [SimplifyCFG][NFC] Renumber blocks when changing func (PR #186666)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 15 06:13:53 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Alexis Engelke (aengelke)
<details>
<summary>Changes</summary>
Keep numbering dense when changing the function. SimplifyCFG is a good candidate, because it is likely to remove blocks and preserves few analyses.
[stage2-O3 -0.07%](http://llvm-compile-time-tracker.com/compare.php?from=a7aebd809d49fd1c8205e8f0fcdc8d97777e5103&to=d77a3d37a5d16025371c3b407838d011cbcc6da9&stat=instructions:u)
---
Full diff: https://github.com/llvm/llvm-project/pull/186666.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp (+5-1)
``````````diff
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;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/186666
More information about the llvm-commits
mailing list