Coverage Report

Created: 2018-09-25 17:16

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/Analysis/TypeBasedAliasAnalysis.h
Line
Count
Source (jump to first uncovered line)
1
//===- TypeBasedAliasAnalysis.h - Type-Based Alias Analysis -----*- C++ -*-===//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
/// \file
11
/// This is the interface for a metadata-based TBAA. See the source file for
12
/// details on the algorithm.
13
//
14
//===----------------------------------------------------------------------===//
15
16
#ifndef LLVM_ANALYSIS_TYPEBASEDALIASANALYSIS_H
17
#define LLVM_ANALYSIS_TYPEBASEDALIASANALYSIS_H
18
19
#include "llvm/Analysis/AliasAnalysis.h"
20
#include "llvm/IR/CallSite.h"
21
#include "llvm/IR/PassManager.h"
22
#include "llvm/Pass.h"
23
#include <memory>
24
25
namespace llvm {
26
27
class Function;
28
class MDNode;
29
class MemoryLocation;
30
31
/// A simple AA result that uses TBAA metadata to answer queries.
32
class TypeBasedAAResult : public AAResultBase<TypeBasedAAResult> {
33
  friend AAResultBase<TypeBasedAAResult>;
34
35
public:
36
  /// Handle invalidation events from the new pass manager.
37
  ///
38
  /// By definition, this result is stateless and so remains valid.
39
  bool invalidate(Function &, const PreservedAnalyses &,
40
260
                  FunctionAnalysisManager::Invalidator &) {
41
260
    return false;
42
260
  }
43
44
  AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB);
45
  bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal);
46
  FunctionModRefBehavior getModRefBehavior(ImmutableCallSite CS);
47
  FunctionModRefBehavior getModRefBehavior(const Function *F);
48
  ModRefInfo getModRefInfo(ImmutableCallSite CS, const MemoryLocation &Loc);
49
  ModRefInfo getModRefInfo(ImmutableCallSite CS1, ImmutableCallSite CS2);
50
51
private:
52
  bool Aliases(const MDNode *A, const MDNode *B) const;
53
  bool PathAliases(const MDNode *A, const MDNode *B) const;
54
};
55
56
/// Analysis pass providing a never-invalidated alias analysis result.
57
class TypeBasedAA : public AnalysisInfoMixin<TypeBasedAA> {
58
  friend AnalysisInfoMixin<TypeBasedAA>;
59
60
  static AnalysisKey Key;
61
62
public:
63
  using Result = TypeBasedAAResult;
64
65
  TypeBasedAAResult run(Function &F, FunctionAnalysisManager &AM);
66
};
67
68
/// Legacy wrapper pass to provide the TypeBasedAAResult object.
69
class TypeBasedAAWrapperPass : public ImmutablePass {
70
  std::unique_ptr<TypeBasedAAResult> Result;
71
72
public:
73
  static char ID;
74
75
  TypeBasedAAWrapperPass();
76
77
10.4M
  TypeBasedAAResult &getResult() { return *Result; }
78
0
  const TypeBasedAAResult &getResult() const { return *Result; }
79
80
  bool doInitialization(Module &M) override;
81
  bool doFinalization(Module &M) override;
82
  void getAnalysisUsage(AnalysisUsage &AU) const override;
83
};
84
85
//===--------------------------------------------------------------------===//
86
//
87
// createTypeBasedAAWrapperPass - This pass implements metadata-based
88
// type-based alias analysis.
89
//
90
ImmutablePass *createTypeBasedAAWrapperPass();
91
92
} // end namespace llvm
93
94
#endif // LLVM_ANALYSIS_TYPEBASEDALIASANALYSIS_H