Skip to content

Conversation

jurahul
Copy link
Contributor

@jurahul jurahul commented Oct 6, 2025

No description provided.

@jurahul jurahul marked this pull request as ready for review October 7, 2025 00:11
@jurahul jurahul requested a review from kazutakahirata October 7, 2025 00:11
@llvmbot
Copy link
Member

llvmbot commented Oct 7, 2025

@llvm/pr-subscribers-llvm-transforms

Author: Rahul Joshi (jurahul)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/162179.diff

1 Files Affected:

  • (modified) llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp (+15-13)
diff --git a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
index e9a3e983bc1e2..506980455d782 100644
--- a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
+++ b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
@@ -121,7 +121,6 @@ static cl::opt<unsigned>
                   cl::Hidden, cl::init(50));
 
 namespace {
-
 class SelectInstToUnfold {
   SelectInst *SI;
   PHINode *SIUse;
@@ -134,11 +133,14 @@ class SelectInstToUnfold {
 
   explicit operator bool() const { return SI && SIUse; }
 };
+} // namespace
 
-void unfold(DomTreeUpdater *DTU, LoopInfo *LI, SelectInstToUnfold SIToUnfold,
-            std::vector<SelectInstToUnfold> *NewSIsToUnfold,
-            std::vector<BasicBlock *> *NewBBs);
+static void unfold(DomTreeUpdater *DTU, LoopInfo *LI,
+                   SelectInstToUnfold SIToUnfold,
+                   std::vector<SelectInstToUnfold> *NewSIsToUnfold,
+                   std::vector<BasicBlock *> *NewBBs);
 
+namespace {
 class DFAJumpThreading {
 public:
   DFAJumpThreading(AssumptionCache *AC, DominatorTree *DT, LoopInfo *LI,
@@ -173,10 +175,7 @@ class DFAJumpThreading {
   TargetTransformInfo *TTI;
   OptimizationRemarkEmitter *ORE;
 };
-
-} // end anonymous namespace
-
-namespace {
+} // namespace
 
 /// Unfold the select instruction held in \p SIToUnfold by replacing it with
 /// control flow.
@@ -185,9 +184,10 @@ namespace {
 /// created basic blocks into \p NewBBs.
 ///
 /// TODO: merge it with CodeGenPrepare::optimizeSelectInst() if possible.
-void unfold(DomTreeUpdater *DTU, LoopInfo *LI, SelectInstToUnfold SIToUnfold,
-            std::vector<SelectInstToUnfold> *NewSIsToUnfold,
-            std::vector<BasicBlock *> *NewBBs) {
+static void unfold(DomTreeUpdater *DTU, LoopInfo *LI,
+                   SelectInstToUnfold SIToUnfold,
+                   std::vector<SelectInstToUnfold> *NewSIsToUnfold,
+                   std::vector<BasicBlock *> *NewBBs) {
   SelectInst *SI = SIToUnfold.getInst();
   PHINode *SIUse = SIToUnfold.getUse();
   assert(SI->hasOneUse());
@@ -342,10 +342,12 @@ void unfold(DomTreeUpdater *DTU, LoopInfo *LI, SelectInstToUnfold SIToUnfold,
   SI->eraseFromParent();
 }
 
+namespace {
 struct ClonedBlock {
   BasicBlock *BB;
   APInt State; ///< \p State corresponds to the next value of a switch stmnt.
 };
+} // namespace
 
 typedef std::deque<BasicBlock *> PathType;
 typedef std::vector<PathType> PathsType;
@@ -379,6 +381,7 @@ inline raw_ostream &operator<<(raw_ostream &OS, const PathType &Path) {
 /// by cloning necessary basic blocks and replacing conditional branches with
 /// unconditional ones. A threading path includes a list of basic blocks, the
 /// exit state, and the block that determines the next state.
+namespace {
 struct ThreadingPath {
   /// Exit value is DFA's exit state for the given path.
   APInt getExitValue() const { return ExitVal; }
@@ -1336,6 +1339,7 @@ struct TransformDFA {
   SmallPtrSet<const Value *, 32> EphValues;
   std::vector<ThreadingPath> TPaths;
 };
+} // namespace
 
 bool DFAJumpThreading::run(Function &F) {
   LLVM_DEBUG(dbgs() << "\nDFA Jump threading: " << F.getName() << "\n");
@@ -1415,8 +1419,6 @@ bool DFAJumpThreading::run(Function &F) {
   return MadeChanges;
 }
 
-} // end anonymous namespace
-
 /// Integrate with the new Pass Manager
 PreservedAnalyses DFAJumpThreadingPass::run(Function &F,
                                             FunctionAnalysisManager &AM) {

@jurahul jurahul requested a review from kazutakahirata October 7, 2025 12:47
Copy link
Contributor

@kazutakahirata kazutakahirata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@jurahul jurahul merged commit b256d0a into llvm:main Oct 7, 2025
9 checks passed
@jurahul jurahul deleted the nfc_namespace_DFAJumpThreading branch October 7, 2025 14:57
@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 7, 2025

LLVM Buildbot has detected a new failure on builder ppc64le-mlir-rhel-clang running on ppc64le-mlir-rhel-test while building llvm at step 6 "test-build-check-mlir-build-only-check-mlir".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/129/builds/31023

Here is the relevant piece of the build log for the reference
Step 6 (test-build-check-mlir-build-only-check-mlir) failure: 1200 seconds without output running [b'ninja', b'check-mlir'], attempting to kill
...
PASS: MLIR :: mlir-tblgen/attr-or-type-format.td (3522 of 3533)
PASS: MLIR :: mlir-tblgen/cpp-class-comments.td (3523 of 3533)
PASS: MLIR :: mlir-tblgen/rewriter-errors.td (3524 of 3533)
PASS: MLIR-Unit :: Interfaces/./MLIRInterfacesTests/11/22 (3525 of 3533)
PASS: MLIR :: Dialect/SCF/loop-unroll.mlir (3526 of 3533)
PASS: MLIR :: Pass/pipeline-options-parsing.mlir (3527 of 3533)
PASS: MLIR :: Pass/pipeline-parsing.mlir (3528 of 3533)
PASS: MLIR :: mlir-runner/simple.mlir (3529 of 3533)
PASS: MLIR :: mlir-reduce/dce-test.mlir (3530 of 3533)
PASS: MLIR :: mlir-tblgen/llvm-intrinsics.td (3531 of 3533)
command timed out: 1200 seconds without output running [b'ninja', b'check-mlir'], attempting to kill
process killed by signal 9
program finished with exit code -1
elapsedTime=1741.331437

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants