1303231Sdim//===- SCCP.cpp - Sparse Conditional Constant Propagation -------*- C++ -*-===//
2303231Sdim//
3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4353358Sdim// See https://llvm.org/LICENSE.txt for license information.
5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6303231Sdim//
7303231Sdim//===----------------------------------------------------------------------===//
8327952Sdim//
9327952Sdim// \file
10303231Sdim// This file implements sparse conditional constant propagation and merging:
11303231Sdim//
12303231Sdim// Specifically, this:
13303231Sdim//   * Assumes values are constant unless proven otherwise
14303231Sdim//   * Assumes BasicBlocks are dead unless proven otherwise
15303231Sdim//   * Proves values to be constant, and replaces them with constants
16303231Sdim//   * Proves conditional branches to be unconditional
17303231Sdim//
18303231Sdim//===----------------------------------------------------------------------===//
19303231Sdim
20303231Sdim#ifndef LLVM_TRANSFORMS_SCALAR_SCCP_H
21303231Sdim#define LLVM_TRANSFORMS_SCALAR_SCCP_H
22303231Sdim
23344779Sdim#include "llvm/ADT/STLExtras.h"
24341825Sdim#include "llvm/Analysis/TargetLibraryInfo.h"
25341825Sdim#include "llvm/IR/DataLayout.h"
26341825Sdim#include "llvm/IR/Function.h"
27341825Sdim#include "llvm/IR/Module.h"
28303231Sdim#include "llvm/IR/PassManager.h"
29344779Sdim#include "llvm/Transforms/Utils/PredicateInfo.h"
30303231Sdim
31303231Sdimnamespace llvm {
32303231Sdim
33344779Sdimclass PostDominatorTree;
34327952Sdim
35303231Sdim/// This pass performs function-level constant propagation and merging.
36303231Sdimclass SCCPPass : public PassInfoMixin<SCCPPass> {
37303231Sdimpublic:
38314564Sdim  PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
39303231Sdim};
40303231Sdim
41344779Sdim/// Helper struct for bundling up the analysis results per function for IPSCCP.
42344779Sdimstruct AnalysisResultsForFn {
43344779Sdim  std::unique_ptr<PredicateInfo> PredInfo;
44344779Sdim  DominatorTree *DT;
45344779Sdim  PostDominatorTree *PDT;
46344779Sdim};
47344779Sdim
48360784Sdimbool runIPSCCP(Module &M, const DataLayout &DL,
49360784Sdim               std::function<const TargetLibraryInfo &(Function &)> GetTLI,
50344779Sdim               function_ref<AnalysisResultsForFn(Function &)> getAnalysis);
51327952Sdim} // end namespace llvm
52327952Sdim
53303231Sdim#endif // LLVM_TRANSFORMS_SCALAR_SCCP_H
54