Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/Transforms/Scalar/MemCpyOptimizer.h
Line
Count
Source
1
//===- MemCpyOptimizer.h - memcpy optimization ------------------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This pass performs various transformations related to eliminating memcpy
10
// calls, or transforming sets of stores into memset's.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_TRANSFORMS_SCALAR_MEMCPYOPTIMIZER_H
15
#define LLVM_TRANSFORMS_SCALAR_MEMCPYOPTIMIZER_H
16
17
#include "llvm/Analysis/AliasAnalysis.h"
18
#include "llvm/IR/BasicBlock.h"
19
#include "llvm/IR/CallSite.h"
20
#include "llvm/IR/PassManager.h"
21
#include <cstdint>
22
#include <functional>
23
24
namespace llvm {
25
26
class AssumptionCache;
27
class CallInst;
28
class DominatorTree;
29
class Function;
30
class Instruction;
31
class MemCpyInst;
32
class MemMoveInst;
33
class MemoryDependenceResults;
34
class MemSetInst;
35
class StoreInst;
36
class TargetLibraryInfo;
37
class Value;
38
39
class MemCpyOptPass : public PassInfoMixin<MemCpyOptPass> {
40
  MemoryDependenceResults *MD = nullptr;
41
  TargetLibraryInfo *TLI = nullptr;
42
  std::function<AliasAnalysis &()> LookupAliasAnalysis;
43
  std::function<AssumptionCache &()> LookupAssumptionCache;
44
  std::function<DominatorTree &()> LookupDomTree;
45
46
public:
47
13.6k
  MemCpyOptPass() = default;
48
49
  PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
50
51
  // Glue for the old PM.
52
  bool runImpl(Function &F, MemoryDependenceResults *MD_,
53
               TargetLibraryInfo *TLI_,
54
               std::function<AliasAnalysis &()> LookupAliasAnalysis_,
55
               std::function<AssumptionCache &()> LookupAssumptionCache_,
56
               std::function<DominatorTree &()> LookupDomTree_);
57
58
private:
59
  // Helper functions
60
  bool processStore(StoreInst *SI, BasicBlock::iterator &BBI);
61
  bool processMemSet(MemSetInst *SI, BasicBlock::iterator &BBI);
62
  bool processMemCpy(MemCpyInst *M);
63
  bool processMemMove(MemMoveInst *M);
64
  bool performCallSlotOptzn(Instruction *cpy, Value *cpyDst, Value *cpySrc,
65
                            uint64_t cpyLen, unsigned cpyAlign, CallInst *C);
66
  bool processMemCpyMemCpyDependence(MemCpyInst *M, MemCpyInst *MDep);
67
  bool processMemSetMemCpyDependence(MemCpyInst *M, MemSetInst *MDep);
68
  bool performMemCpyToMemSetOptzn(MemCpyInst *M, MemSetInst *MDep);
69
  bool processByValArgument(CallSite CS, unsigned ArgNo);
70
  Instruction *tryMergingIntoMemset(Instruction *I, Value *StartPtr,
71
                                    Value *ByteVal);
72
73
  bool iterateOnFunction(Function &F);
74
};
75
76
} // end namespace llvm
77
78
#endif // LLVM_TRANSFORMS_SCALAR_MEMCPYOPTIMIZER_H