#include "llvm/Transforms/Utils/AssumeBundleBuilder.h"
#include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/AssumeBundleQueries.h"
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Operator.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/DebugCounter.h"
#include "llvm/Transforms/Utils/Local.h"
usingnamespacellvm;
namespace llvm {
cl::opt<bool> ShouldPreserveAllAttributes(
"assume-preserve-all", cl::init(false), cl::Hidden,
cl::desc("enable preservation of all attrbitues. even those that are "
"unlikely to be usefull"));
cl::opt<bool> EnableKnowledgeRetention(
"enable-knowledge-retention", cl::init(false), cl::Hidden,
cl::desc(
"enable preservation of attributes throughout code transformation"));
}
#define DEBUG_TYPE …
STATISTIC(NumAssumeBuilt, "Number of assume built by the assume builder");
STATISTIC(NumBundlesInAssumes, "Total number of Bundles in the assume built");
STATISTIC(NumAssumesMerged,
"Number of assume merged by the assume simplify pass");
STATISTIC(NumAssumesRemoved,
"Number of assume removed by the assume simplify pass");
DEBUG_COUNTER(BuildAssumeCounter, "assume-builder-counter",
"Controls which assumes gets created");
namespace {
bool isUsefullToPreserve(Attribute::AttrKind Kind) { … }
RetainedKnowledge canonicalizedKnowledge(RetainedKnowledge RK,
const DataLayout &DL) { … }
struct AssumeBuilderState { … };
}
AssumeInst *llvm::buildAssumeFromInst(Instruction *I) { … }
bool llvm::salvageKnowledge(Instruction *I, AssumptionCache *AC,
DominatorTree *DT) { … }
AssumeInst *
llvm::buildAssumeFromKnowledge(ArrayRef<RetainedKnowledge> Knowledge,
Instruction *CtxI, AssumptionCache *AC,
DominatorTree *DT) { … }
RetainedKnowledge llvm::simplifyRetainedKnowledge(AssumeInst *Assume,
RetainedKnowledge RK,
AssumptionCache *AC,
DominatorTree *DT) { … }
namespace {
struct AssumeSimplify { … };
bool simplifyAssumes(Function &F, AssumptionCache *AC, DominatorTree *DT) { … }
}
PreservedAnalyses AssumeSimplifyPass::run(Function &F,
FunctionAnalysisManager &AM) { … }
PreservedAnalyses AssumeBuilderPass::run(Function &F,
FunctionAnalysisManager &AM) { … }