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 @@ -1558,6 +1558,14 @@ class Instruction : public sandboxir::User {
15581558 void moveAfter (Instruction *After) {
15591559 moveBefore (*After->getParent (), std::next (After->getIterator ()));
15601560 }
1561+ // TODO: This currently relies on LLVM IR Instruction::comesBefore which is
1562+ // can be linear-time.
1563+ // / Given an instruction Other in the same basic block as this instruction,
1564+ // / return true if this instruction comes before Other.
1565+ bool comesBefore (const Instruction *Other) const {
1566+ return cast<llvm::Instruction>(Val)->comesBefore (
1567+ cast<llvm::Instruction>(Other->Val ));
1568+ }
15611569 // / \Returns the BasicBlock containing this Instruction, or null if it is
15621570 // / detached.
15631571 BasicBlock *getParent () const ;
Original file line number Diff line number Diff line change @@ -1366,6 +1366,10 @@ define void @foo(i8 %v1) {
13661366 EXPECT_EQ (I0->getNextNode (), I1);
13671367 EXPECT_EQ (I1->getPrevNode (), I0);
13681368
1369+ // Check comesBefore(I).
1370+ EXPECT_TRUE (I0->comesBefore (I1));
1371+ EXPECT_FALSE (I1->comesBefore (I0));
1372+
13691373 // Check moveBefore(BB, It).
13701374 I1->moveBefore (*BB, BB->begin ());
13711375 EXPECT_EQ (I1->getPrevNode (), nullptr );
You can’t perform that action at this time.
0 commit comments