Skip to content

Commit 9ebaf4f

Browse files
committed
[IPSCCP] Move the IPSCCP run function under the IPO directory.
Reland 42c2dc4 which was reverted in cb03b1b. The fix for the link errors was to reintroduce one of the two occurences of 'Scalar' under the LINK_COMPONENTS. Differential Revision: https://reviews.llvm.org/D138654
1 parent d576537 commit 9ebaf4f

File tree

8 files changed

+598
-614
lines changed

8 files changed

+598
-614
lines changed

llvm/include/llvm/Transforms/Scalar/SCCP.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ class SCCPPass : public PassInfoMixin<SCCPPass> {
4040
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
4141
};
4242

43-
bool runIPSCCP(Module &M, const DataLayout &DL,
44-
std::function<const TargetLibraryInfo &(Function &)> GetTLI,
45-
function_ref<AnalysisResultsForFn(Function &)> getAnalysis);
46-
4743
bool runFunctionSpecialization(
4844
Module &M, FunctionAnalysisManager *FAM, const DataLayout &DL,
4945
std::function<TargetLibraryInfo &(Function &)> GetTLI,

llvm/include/llvm/Transforms/Utils/SCCPSolver.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#define LLVM_TRANSFORMS_UTILS_SCCPSOLVER_H
1616

1717
#include "llvm/ADT/MapVector.h"
18+
#include "llvm/ADT/SmallPtrSet.h"
19+
#include "llvm/ADT/Statistic.h"
1820
#include "llvm/Analysis/DomTreeUpdater.h"
1921
#include "llvm/Transforms/Utils/PredicateInfo.h"
2022
#include <vector>
@@ -173,6 +175,24 @@ class SCCPSolver {
173175
void visitCall(CallInst &I);
174176
};
175177

178+
//===----------------------------------------------------------------------===//
179+
//
180+
/// Helper functions used by the SCCP and IPSCCP passes.
181+
//
182+
bool isConstant(const ValueLatticeElement &LV);
183+
184+
bool isOverdefined(const ValueLatticeElement &LV);
185+
186+
bool simplifyInstsInBlock(SCCPSolver &Solver, BasicBlock &BB,
187+
SmallPtrSetImpl<Value *> &InsertedValues,
188+
Statistic &InstRemovedStat,
189+
Statistic &InstReplacedStat);
190+
191+
bool tryToReplaceWithConstant(SCCPSolver &Solver, Value *V);
192+
193+
bool removeNonFeasibleEdges(const llvm::SCCPSolver &Solver, BasicBlock *BB,
194+
DomTreeUpdater &DTU,
195+
BasicBlock *&NewUnreachableBB);
176196
} // namespace llvm
177197

178198
#endif // LLVM_TRANSFORMS_UTILS_SCCPSOLVER_H

llvm/lib/Transforms/IPO/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,4 @@ add_llvm_component_library(LLVMipo
7171
TransformUtils
7272
Vectorize
7373
Instrumentation
74-
Scalar
7574
)

llvm/lib/Transforms/IPO/FunctionSpecialization.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -124,20 +124,6 @@ using CallSpecBinding = std::pair<CallBase *, SpecializationInfo>;
124124
// order across executions.
125125
using SpecializationMap = SmallMapVector<CallBase *, SpecializationInfo, 8>;
126126

127-
// Helper to check if \p LV is either a constant or a constant
128-
// range with a single element. This should cover exactly the same cases as the
129-
// old ValueLatticeElement::isConstant() and is intended to be used in the
130-
// transition to ValueLatticeElement.
131-
static bool isConstant(const ValueLatticeElement &LV) {
132-
return LV.isConstant() ||
133-
(LV.isConstantRange() && LV.getConstantRange().isSingleElement());
134-
}
135-
136-
// Helper to check if \p LV is either overdefined or a constant int.
137-
static bool isOverdefined(const ValueLatticeElement &LV) {
138-
return !LV.isUnknownOrUndef() && !isConstant(LV);
139-
}
140-
141127
static Constant *getPromotableAlloca(AllocaInst *Alloca, CallInst *Call) {
142128
Value *StoreValue = nullptr;
143129
for (auto *User : Alloca->users()) {

0 commit comments

Comments
 (0)