[PATCH] D74931: [Dominators] Use Instruction::comesBefore for block-local queries, NFC

Vedant Kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 20 14:21:11 PST 2020


vsk created this revision.
vsk added reviewers: kuhar, rnk, dexonsmith.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

Use the lazy instruction ordering facility for block-local dominance
queries. IIUC this was just left out of https://reviews.llvm.org/D51664
as it was rebased.


https://reviews.llvm.org/D74931

Files:
  llvm/lib/IR/Dominators.cpp


Index: llvm/lib/IR/Dominators.cpp
===================================================================
--- llvm/lib/IR/Dominators.cpp
+++ llvm/lib/IR/Dominators.cpp
@@ -140,12 +140,7 @@
   if (DefBB != UseBB)
     return dominates(DefBB, UseBB);
 
-  // Loop through the basic block until we find Def or User.
-  BasicBlock::const_iterator I = DefBB->begin();
-  for (; &*I != Def && &*I != User; ++I)
-    /*empty*/;
-
-  return &*I == Def;
+  return Def->comesBefore(User);
 }
 
 // true if Def would dominate a use in any instruction in UseBB.
@@ -289,12 +284,7 @@
   if (isa<PHINode>(UserInst))
     return true;
 
-  // Otherwise, just loop through the basic block until we find Def or User.
-  BasicBlock::const_iterator I = DefBB->begin();
-  for (; &*I != Def && &*I != UserInst; ++I)
-    /*empty*/;
-
-  return &*I != UserInst;
+  return Def->comesBefore(UserInst);
 }
 
 bool DominatorTree::isReachableFromEntry(const Use &U) const {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74931.245744.patch
Type: text/x-patch
Size: 944 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200220/ec11cbd4/attachment.bin>


More information about the llvm-commits mailing list