Skip to content

Commit

Permalink
Revert "[IPSCCP] Move the IPSCCP run function under the IPO directory."
Browse files Browse the repository at this point in the history
This reverts commit 42c2dc4.

This broke some buildbots:

 undefined reference to `llvm::createBitTrackingDCEPass()'
 undefined reference to `llvm::createAlignmentFromAssumptionsPass()'
 undefined reference to `llvm::createLoopUnrollPass(int, bool, bool, int, int, int, int, int, int)'
 undefined reference to `llvm::createLICMPass(unsigned int, unsigned int, bool)'
 undefined reference to `llvm::createWarnMissedTransformationsPass()'
 undefined reference to `llvm::createAlignmentFromAssumptionsPass()'
 undefined reference to `llvm::createCallSiteSplittingPass()'
 undefined reference to `llvm::createCFGSimplificationPass(llvm::SimplifyCFGOptions, std::function<bool (llvm::Function const&)>)'
 undefined reference to `llvm::createFloat2IntPass()'
 undefined reference to `llvm::createLowerConstantIntrinsicsPass()'
 undefined reference to `llvm::createLoopRotatePass(int, bool)'
 undefined reference to `llvm::createLoopDistributePass()'
 undefined reference to `llvm::createLoopSinkPass()'
 undefined reference to `llvm::createInstSimplifyLegacyPass()'
 undefined reference to `llvm::createDivRemPairsPass()'
 undefined reference to `llvm::createCFGSimplificationPass(llvm::SimplifyCFGOptions, std::function<bool (llvm::Function const&)>)'
 undefined reference to `llvm::SetLicmMssaOptCap'
 undefined reference to `llvm::SetLicmMssaNoAccForPromotionCap'
 undefined reference to `llvm::ForgetSCEVInLoopUnroll'
  • Loading branch information
labrinea committed Dec 8, 2022
1 parent 0f0cb92 commit cb03b1b
Show file tree
Hide file tree
Showing 8 changed files with 615 additions and 598 deletions.
4 changes: 4 additions & 0 deletions llvm/include/llvm/Transforms/Scalar/SCCP.h
Expand Up @@ -40,6 +40,10 @@ class SCCPPass : public PassInfoMixin<SCCPPass> {
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
};

bool runIPSCCP(Module &M, const DataLayout &DL,
std::function<const TargetLibraryInfo &(Function &)> GetTLI,
function_ref<AnalysisResultsForFn(Function &)> getAnalysis);

bool runFunctionSpecialization(
Module &M, FunctionAnalysisManager *FAM, const DataLayout &DL,
std::function<TargetLibraryInfo &(Function &)> GetTLI,
Expand Down
20 changes: 0 additions & 20 deletions llvm/include/llvm/Transforms/Utils/SCCPSolver.h
Expand Up @@ -15,8 +15,6 @@
#define LLVM_TRANSFORMS_UTILS_SCCPSOLVER_H

#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/DomTreeUpdater.h"
#include "llvm/Transforms/Utils/PredicateInfo.h"
#include <vector>
Expand Down Expand Up @@ -175,24 +173,6 @@ class SCCPSolver {
void visitCall(CallInst &I);
};

//===----------------------------------------------------------------------===//
//
/// Helper functions used by the SCCP and IPSCCP passes.
//
bool isConstant(const ValueLatticeElement &LV);

bool isOverdefined(const ValueLatticeElement &LV);

bool simplifyInstsInBlock(SCCPSolver &Solver, BasicBlock &BB,
SmallPtrSetImpl<Value *> &InsertedValues,
Statistic &InstRemovedStat,
Statistic &InstReplacedStat);

bool tryToReplaceWithConstant(SCCPSolver &Solver, Value *V);

bool removeNonFeasibleEdges(const llvm::SCCPSolver &Solver, BasicBlock *BB,
DomTreeUpdater &DTU,
BasicBlock *&NewUnreachableBB);
} // namespace llvm

#endif // LLVM_TRANSFORMS_UTILS_SCCPSOLVER_H
2 changes: 2 additions & 0 deletions llvm/lib/Transforms/IPO/CMakeLists.txt
Expand Up @@ -66,8 +66,10 @@ add_llvm_component_library(LLVMipo
Linker
Object
ProfileData
Scalar
Support
TransformUtils
Vectorize
Instrumentation
Scalar
)
14 changes: 14 additions & 0 deletions llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
Expand Up @@ -124,6 +124,20 @@ using CallSpecBinding = std::pair<CallBase *, SpecializationInfo>;
// order across executions.
using SpecializationMap = SmallMapVector<CallBase *, SpecializationInfo, 8>;

// Helper to check if \p LV is either a constant or a constant
// range with a single element. This should cover exactly the same cases as the
// old ValueLatticeElement::isConstant() and is intended to be used in the
// transition to ValueLatticeElement.
static bool isConstant(const ValueLatticeElement &LV) {
return LV.isConstant() ||
(LV.isConstantRange() && LV.getConstantRange().isSingleElement());
}

// Helper to check if \p LV is either overdefined or a constant int.
static bool isOverdefined(const ValueLatticeElement &LV) {
return !LV.isUnknownOrUndef() && !isConstant(LV);
}

static Constant *getPromotableAlloca(AllocaInst *Alloca, CallInst *Call) {
Value *StoreValue = nullptr;
for (auto *User : Alloca->users()) {
Expand Down

0 comments on commit cb03b1b

Please sign in to comment.