Skip to content

Commit

Permalink
[CodeMoverUtils] Move OrderedInstructions to CodeMoverUtils
Browse files Browse the repository at this point in the history
Summary: This patch moves OrderedInstructions to CodeMoverUtils as It was
the only place where OrderedInstructions is required.
Authored By: RithikSharma
Reviewer: Whitney, bmahjour, etiotto, fhahn, nikic
Reviewed By: Whitney, nikic
Subscribers: mgorny, hiraditya, llvm-commits
Tag: LLVM
Differential Revision: https://reviews.llvm.org/D80643
  • Loading branch information
SharmaRithik committed Jul 10, 2020
1 parent 760bbda commit e71c7b5
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 188 deletions.
57 changes: 0 additions & 57 deletions llvm/include/llvm/Analysis/OrderedInstructions.h

This file was deleted.

1 change: 0 additions & 1 deletion llvm/lib/Analysis/CMakeLists.txt
Expand Up @@ -90,7 +90,6 @@ add_llvm_component_library(LLVMAnalysis
ObjCARCAnalysisUtils.cpp
ObjCARCInstKind.cpp
OptimizationRemarkEmitter.cpp
OrderedInstructions.cpp
PHITransAddr.cpp
PhiValues.cpp
PostDominators.cpp
Expand Down
59 changes: 0 additions & 59 deletions llvm/lib/Analysis/OrderedInstructions.cpp

This file was deleted.

16 changes: 13 additions & 3 deletions llvm/lib/Transforms/Utils/CodeMoverUtils.cpp
Expand Up @@ -15,7 +15,6 @@
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/DependenceAnalysis.h"
#include "llvm/Analysis/OrderedInstructions.h"
#include "llvm/Analysis/PostDominators.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/Dominators.h"
Expand Down Expand Up @@ -94,6 +93,18 @@ class ControlConditions {
};
} // namespace

static bool domTreeLevelBefore(DominatorTree *DT, const Instruction *InstA,
const Instruction *InstB) {
// Use ordered basic block in case the 2 instructions are in the same
// block.
if (InstA->getParent() == InstB->getParent())
return InstA->comesBefore(InstB);

DomTreeNode *DA = DT->getNode(InstA->getParent());
DomTreeNode *DB = DT->getNode(InstB->getParent());
return DA->getLevel() < DB->getLevel();
}

const Optional<ControlConditions> ControlConditions::collectControlConditions(
const BasicBlock &BB, const BasicBlock &Dominator, const DominatorTree &DT,
const PostDominatorTree &PDT, unsigned MaxLookup) {
Expand Down Expand Up @@ -332,9 +343,8 @@ bool llvm::isSafeToMoveBefore(Instruction &I, Instruction &InsertPoint,
if (&InsertPoint == OpInst || !DT.dominates(OpInst, &InsertPoint))
return false;

OrderedInstructions OI(&DT);
DT.updateDFSNumbers();
const bool MoveForward = OI.domTreeLevelBefore(&I, &InsertPoint);
const bool MoveForward = domTreeLevelBefore(&DT, &I, &InsertPoint);
Instruction &StartInst = (MoveForward ? I : InsertPoint);
Instruction &EndInst = (MoveForward ? InsertPoint : I);
SmallPtrSet<Instruction *, 10> InstsToCheck;
Expand Down
3 changes: 1 addition & 2 deletions llvm/unittests/Analysis/CMakeLists.txt
Expand Up @@ -29,7 +29,6 @@ add_llvm_unittest(AnalysisTests
LoopNestTest.cpp
MemoryBuiltinsTest.cpp
MemorySSATest.cpp
OrderedInstructionsTest.cpp
PhiValuesTest.cpp
ProfileSummaryInfoTest.cpp
ScalarEvolutionTest.cpp
Expand All @@ -41,4 +40,4 @@ add_llvm_unittest(AnalysisTests
ValueLatticeTest.cpp
ValueTrackingTest.cpp
VectorUtilsTest.cpp
)
)
64 changes: 0 additions & 64 deletions llvm/unittests/Analysis/OrderedInstructionsTest.cpp

This file was deleted.

1 change: 0 additions & 1 deletion llvm/utils/gn/secondary/llvm/lib/Analysis/BUILD.gn
Expand Up @@ -88,7 +88,6 @@ static_library("Analysis") {
"ObjCARCAnalysisUtils.cpp",
"ObjCARCInstKind.cpp",
"OptimizationRemarkEmitter.cpp",
"OrderedInstructions.cpp",
"PHITransAddr.cpp",
"PhiValues.cpp",
"PostDominators.cpp",
Expand Down
1 change: 0 additions & 1 deletion llvm/utils/gn/secondary/llvm/unittests/Analysis/BUILD.gn
Expand Up @@ -31,7 +31,6 @@ unittest("AnalysisTests") {
"LoopNestTest.cpp",
"MemoryBuiltinsTest.cpp",
"MemorySSATest.cpp",
"OrderedInstructionsTest.cpp",
"PhiValuesTest.cpp",
"ProfileSummaryInfoTest.cpp",
"ScalarEvolutionTest.cpp",
Expand Down

0 comments on commit e71c7b5

Please sign in to comment.