File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -1643,6 +1643,14 @@ class Instruction : public sandboxir::User {
16431643 void moveAfter (Instruction *After) {
16441644 moveBefore (*After->getParent (), std::next (After->getIterator ()));
16451645 }
1646+ // TODO: This currently relies on LLVM IR Instruction::comesBefore which is
1647+ // can be linear-time.
1648+ // / Given an instruction Other in the same basic block as this instruction,
1649+ // / return true if this instruction comes before Other.
1650+ bool comesBefore (const Instruction *Other) const {
1651+ return cast<llvm::Instruction>(Val)->comesBefore (
1652+ cast<llvm::Instruction>(Other->Val ));
1653+ }
16461654 // / \Returns the BasicBlock containing this Instruction, or null if it is
16471655 // / detached.
16481656 BasicBlock *getParent () const ;
Original file line number Diff line number Diff line change @@ -1473,6 +1473,10 @@ define void @foo(i8 %v1) {
14731473 EXPECT_EQ (I0->getNextNode (), I1);
14741474 EXPECT_EQ (I1->getPrevNode (), I0);
14751475
1476+ // Check comesBefore(I).
1477+ EXPECT_TRUE (I0->comesBefore (I1));
1478+ EXPECT_FALSE (I1->comesBefore (I0));
1479+
14761480 // Check moveBefore(BB, It).
14771481 I1->moveBefore (*BB, BB->begin ());
14781482 EXPECT_EQ (I1->getPrevNode (), nullptr );
You can’t perform that action at this time.
0 commit comments