File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -1558,6 +1558,13 @@ class Instruction : public sandboxir::User {
1558
1558
void moveAfter (Instruction *After) {
1559
1559
moveBefore (*After->getParent (), std::next (After->getIterator ()));
1560
1560
}
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<Instruction>(Val)->comesBefore (Other);
1567
+ }
1561
1568
// / \Returns the BasicBlock containing this Instruction, or null if it is
1562
1569
// / detached.
1563
1570
BasicBlock *getParent () const ;
Original file line number Diff line number Diff line change @@ -1366,6 +1366,10 @@ define void @foo(i8 %v1) {
1366
1366
EXPECT_EQ (I0->getNextNode (), I1);
1367
1367
EXPECT_EQ (I1->getPrevNode (), I0);
1368
1368
1369
+ // Check comesBefore(I).
1370
+ EXPECT_TRUE (I0->comesBefore (I1));
1371
+ EXPECT_FALSE (I1->comesBefore (I0));
1372
+
1369
1373
// Check moveBefore(BB, It).
1370
1374
I1->moveBefore (*BB, BB->begin ());
1371
1375
EXPECT_EQ (I1->getPrevNode (), nullptr );
You can’t perform that action at this time.
0 commit comments