Coverage Report

Created: 2019-03-22 08:08

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/Analysis/AliasAnalysis.h
Line
Count
Source (jump to first uncovered line)
1
//===- llvm/Analysis/AliasAnalysis.h - Alias Analysis Interface -*- 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 file defines the generic AliasAnalysis interface, which is used as the
10
// common interface used by all clients of alias analysis information, and
11
// implemented by all alias analysis implementations.  Mod/Ref information is
12
// also captured by this interface.
13
//
14
// Implementations of this interface must implement the various virtual methods,
15
// which automatically provides functionality for the entire suite of client
16
// APIs.
17
//
18
// This API identifies memory regions with the MemoryLocation class. The pointer
19
// component specifies the base memory address of the region. The Size specifies
20
// the maximum size (in address units) of the memory region, or
21
// MemoryLocation::UnknownSize if the size is not known. The TBAA tag
22
// identifies the "type" of the memory reference; see the
23
// TypeBasedAliasAnalysis class for details.
24
//
25
// Some non-obvious details include:
26
//  - Pointers that point to two completely different objects in memory never
27
//    alias, regardless of the value of the Size component.
28
//  - NoAlias doesn't imply inequal pointers. The most obvious example of this
29
//    is two pointers to constant memory. Even if they are equal, constant
30
//    memory is never stored to, so there will never be any dependencies.
31
//    In this and other situations, the pointers may be both NoAlias and
32
//    MustAlias at the same time. The current API can only return one result,
33
//    though this is rarely a problem in practice.
34
//
35
//===----------------------------------------------------------------------===//
36
37
#ifndef LLVM_ANALYSIS_ALIASANALYSIS_H
38
#define LLVM_ANALYSIS_ALIASANALYSIS_H
39
40
#include "llvm/ADT/None.h"
41
#include "llvm/ADT/Optional.h"
42
#include "llvm/ADT/SmallVector.h"
43
#include "llvm/Analysis/MemoryLocation.h"
44
#include "llvm/Analysis/TargetLibraryInfo.h"
45
#include "llvm/IR/Function.h"
46
#include "llvm/IR/Instruction.h"
47
#include "llvm/IR/Instructions.h"
48
#include "llvm/IR/PassManager.h"
49
#include "llvm/Pass.h"
50
#include <cstdint>
51
#include <functional>
52
#include <memory>
53
#include <vector>
54
55
namespace llvm {
56
57
class AnalysisUsage;
58
class BasicAAResult;
59
class BasicBlock;
60
class DominatorTree;
61
class OrderedBasicBlock;
62
class Value;
63
64
/// The possible results of an alias query.
65
///
66
/// These results are always computed between two MemoryLocation objects as
67
/// a query to some alias analysis.
68
///
69
/// Note that these are unscoped enumerations because we would like to support
70
/// implicitly testing a result for the existence of any possible aliasing with
71
/// a conversion to bool, but an "enum class" doesn't support this. The
72
/// canonical names from the literature are suffixed and unique anyways, and so
73
/// they serve as global constants in LLVM for these results.
74
///
75
/// See docs/AliasAnalysis.html for more information on the specific meanings
76
/// of these values.
77
enum AliasResult : uint8_t {
78
  /// The two locations do not alias at all.
79
  ///
80
  /// This value is arranged to convert to false, while all other values
81
  /// convert to true. This allows a boolean context to convert the result to
82
  /// a binary flag indicating whether there is the possibility of aliasing.
83
  NoAlias = 0,
84
  /// The two locations may or may not alias. This is the least precise result.
85
  MayAlias,
86
  /// The two locations alias, but only due to a partial overlap.
87
  PartialAlias,
88
  /// The two locations precisely alias each other.
89
  MustAlias,
90
};
91
92
/// << operator for AliasResult.
93
raw_ostream &operator<<(raw_ostream &OS, AliasResult AR);
94
95
/// Flags indicating whether a memory access modifies or references memory.
96
///
97
/// This is no access at all, a modification, a reference, or both
98
/// a modification and a reference. These are specifically structured such that
99
/// they form a three bit matrix and bit-tests for 'mod' or 'ref' or 'must'
100
/// work with any of the possible values.
101
enum class ModRefInfo : uint8_t {
102
  /// Must is provided for completeness, but no routines will return only
103
  /// Must today. See definition of Must below.
104
  Must = 0,
105
  /// The access may reference the value stored in memory,
106
  /// a mustAlias relation was found, and no mayAlias or partialAlias found.
107
  MustRef = 1,
108
  /// The access may modify the value stored in memory,
109
  /// a mustAlias relation was found, and no mayAlias or partialAlias found.
110
  MustMod = 2,
111
  /// The access may reference, modify or both the value stored in memory,
112
  /// a mustAlias relation was found, and no mayAlias or partialAlias found.
113
  MustModRef = MustRef | MustMod,
114
  /// The access neither references nor modifies the value stored in memory.
115
  NoModRef = 4,
116
  /// The access may reference the value stored in memory.
117
  Ref = NoModRef | MustRef,
118
  /// The access may modify the value stored in memory.
119
  Mod = NoModRef | MustMod,
120
  /// The access may reference and may modify the value stored in memory.
121
  ModRef = Ref | Mod,
122
123
  /// About Must:
124
  /// Must is set in a best effort manner.
125
  /// We usually do not try our best to infer Must, instead it is merely
126
  /// another piece of "free" information that is presented when available.
127
  /// Must set means there was certainly a MustAlias found. For calls,
128
  /// where multiple arguments are checked (argmemonly), this translates to
129
  /// only MustAlias or NoAlias was found.
130
  /// Must is not set for RAR accesses, even if the two locations must
131
  /// alias. The reason is that two read accesses translate to an early return
132
  /// of NoModRef. An additional alias check to set Must may be
133
  /// expensive. Other cases may also not set Must(e.g. callCapturesBefore).
134
  /// We refer to Must being *set* when the most significant bit is *cleared*.
135
  /// Conversely we *clear* Must information by *setting* the Must bit to 1.
136
};
137
138
39.0M
LLVM_NODISCARD inline bool isNoModRef(const ModRefInfo MRI) {
139
39.0M
  return (static_cast<int>(MRI) & static_cast<int>(ModRefInfo::MustModRef)) ==
140
39.0M
         static_cast<int>(ModRefInfo::Must);
141
39.0M
}
142
21.9M
LLVM_NODISCARD inline bool isModOrRefSet(const ModRefInfo MRI) {
143
21.9M
  return static_cast<int>(MRI) & static_cast<int>(ModRefInfo::MustModRef);
144
21.9M
}
145
41.1M
LLVM_NODISCARD inline bool isModAndRefSet(const ModRefInfo MRI) {
146
41.1M
  return (static_cast<int>(MRI) & static_cast<int>(ModRefInfo::MustModRef)) ==
147
41.1M
         static_cast<int>(ModRefInfo::MustModRef);
148
41.1M
}
149
66.6M
LLVM_NODISCARD inline bool isModSet(const ModRefInfo MRI) {
150
66.6M
  return static_cast<int>(MRI) & static_cast<int>(ModRefInfo::MustMod);
151
66.6M
}
152
36.4M
LLVM_NODISCARD inline bool isRefSet(const ModRefInfo MRI) {
153
36.4M
  return static_cast<int>(MRI) & static_cast<int>(ModRefInfo::MustRef);
154
36.4M
}
155
7.15M
LLVM_NODISCARD inline bool isMustSet(const ModRefInfo MRI) {
156
7.15M
  return !(static_cast<int>(MRI) & static_cast<int>(ModRefInfo::NoModRef));
157
7.15M
}
158
159
96.5k
LLVM_NODISCARD inline ModRefInfo setMod(const ModRefInfo MRI) {
160
96.5k
  return ModRefInfo(static_cast<int>(MRI) |
161
96.5k
                    static_cast<int>(ModRefInfo::MustMod));
162
96.5k
}
163
123k
LLVM_NODISCARD inline ModRefInfo setRef(const ModRefInfo MRI) {
164
123k
  return ModRefInfo(static_cast<int>(MRI) |
165
123k
                    static_cast<int>(ModRefInfo::MustRef));
166
123k
}
167
495k
LLVM_NODISCARD inline ModRefInfo setMust(const ModRefInfo MRI) {
168
495k
  return ModRefInfo(static_cast<int>(MRI) &
169
495k
                    static_cast<int>(ModRefInfo::MustModRef));
170
495k
}
171
11.4k
LLVM_NODISCARD inline ModRefInfo setModAndRef(const ModRefInfo MRI) {
172
11.4k
  return ModRefInfo(static_cast<int>(MRI) |
173
11.4k
                    static_cast<int>(ModRefInfo::MustModRef));
174
11.4k
}
175
76.7k
LLVM_NODISCARD inline ModRefInfo clearMod(const ModRefInfo MRI) {
176
76.7k
  return ModRefInfo(static_cast<int>(MRI) & static_cast<int>(ModRefInfo::Ref));
177
76.7k
}
178
432
LLVM_NODISCARD inline ModRefInfo clearRef(const ModRefInfo MRI) {
179
432
  return ModRefInfo(static_cast<int>(MRI) & static_cast<int>(ModRefInfo::Mod));
180
432
}
181
40.5M
LLVM_NODISCARD inline ModRefInfo clearMust(const ModRefInfo MRI) {
182
40.5M
  return ModRefInfo(static_cast<int>(MRI) |
183
40.5M
                    static_cast<int>(ModRefInfo::NoModRef));
184
40.5M
}
185
LLVM_NODISCARD inline ModRefInfo unionModRef(const ModRefInfo MRI1,
186
548k
                                             const ModRefInfo MRI2) {
187
548k
  return ModRefInfo(static_cast<int>(MRI1) | static_cast<int>(MRI2));
188
548k
}
189
LLVM_NODISCARD inline ModRefInfo intersectModRef(const ModRefInfo MRI1,
190
43.6M
                                                 const ModRefInfo MRI2) {
191
43.6M
  return ModRefInfo(static_cast<int>(MRI1) & static_cast<int>(MRI2));
192
43.6M
}
193
194
/// The locations at which a function might access memory.
195
///
196
/// These are primarily used in conjunction with the \c AccessKind bits to
197
/// describe both the nature of access and the locations of access for a
198
/// function call.
199
enum FunctionModRefLocation {
200
  /// Base case is no access to memory.
201
  FMRL_Nowhere = 0,
202
  /// Access to memory via argument pointers.
203
  FMRL_ArgumentPointees = 8,
204
  /// Memory that is inaccessible via LLVM IR.
205
  FMRL_InaccessibleMem = 16,
206
  /// Access to any memory.
207
  FMRL_Anywhere = 32 | FMRL_InaccessibleMem | FMRL_ArgumentPointees
208
};
209
210
/// Summary of how a function affects memory in the program.
211
///
212
/// Loads from constant globals are not considered memory accesses for this
213
/// interface. Also, functions may freely modify stack space local to their
214
/// invocation without having to report it through these interfaces.
215
enum FunctionModRefBehavior {
216
  /// This function does not perform any non-local loads or stores to memory.
217
  ///
218
  /// This property corresponds to the GCC 'const' attribute.
219
  /// This property corresponds to the LLVM IR 'readnone' attribute.
220
  /// This property corresponds to the IntrNoMem LLVM intrinsic flag.
221
  FMRB_DoesNotAccessMemory =
222
      FMRL_Nowhere | static_cast<int>(ModRefInfo::NoModRef),
223
224
  /// The only memory references in this function (if it has any) are
225
  /// non-volatile loads from objects pointed to by its pointer-typed
226
  /// arguments, with arbitrary offsets.
227
  ///
228
  /// This property corresponds to the IntrReadArgMem LLVM intrinsic flag.
229
  FMRB_OnlyReadsArgumentPointees =
230
      FMRL_ArgumentPointees | static_cast<int>(ModRefInfo::Ref),
231
232
  /// The only memory references in this function (if it has any) are
233
  /// non-volatile loads and stores from objects pointed to by its
234
  /// pointer-typed arguments, with arbitrary offsets.
235
  ///
236
  /// This property corresponds to the IntrArgMemOnly LLVM intrinsic flag.
237
  FMRB_OnlyAccessesArgumentPointees =
238
      FMRL_ArgumentPointees | static_cast<int>(ModRefInfo::ModRef),
239
240
  /// The only memory references in this function (if it has any) are
241
  /// references of memory that is otherwise inaccessible via LLVM IR.
242
  ///
243
  /// This property corresponds to the LLVM IR inaccessiblememonly attribute.
244
  FMRB_OnlyAccessesInaccessibleMem =
245
      FMRL_InaccessibleMem | static_cast<int>(ModRefInfo::ModRef),
246
247
  /// The function may perform non-volatile loads and stores of objects
248
  /// pointed to by its pointer-typed arguments, with arbitrary offsets, and
249
  /// it may also perform loads and stores of memory that is otherwise
250
  /// inaccessible via LLVM IR.
251
  ///
252
  /// This property corresponds to the LLVM IR
253
  /// inaccessiblemem_or_argmemonly attribute.
254
  FMRB_OnlyAccessesInaccessibleOrArgMem = FMRL_InaccessibleMem |
255
                                          FMRL_ArgumentPointees |
256
                                          static_cast<int>(ModRefInfo::ModRef),
257
258
  /// This function does not perform any non-local stores or volatile loads,
259
  /// but may read from any memory location.
260
  ///
261
  /// This property corresponds to the GCC 'pure' attribute.
262
  /// This property corresponds to the LLVM IR 'readonly' attribute.
263
  /// This property corresponds to the IntrReadMem LLVM intrinsic flag.
264
  FMRB_OnlyReadsMemory = FMRL_Anywhere | static_cast<int>(ModRefInfo::Ref),
265
266
  // This function does not read from memory anywhere, but may write to any
267
  // memory location.
268
  //
269
  // This property corresponds to the LLVM IR 'writeonly' attribute.
270
  // This property corresponds to the IntrWriteMem LLVM intrinsic flag.
271
  FMRB_DoesNotReadMemory = FMRL_Anywhere | static_cast<int>(ModRefInfo::Mod),
272
273
  /// This indicates that the function could not be classified into one of the
274
  /// behaviors above.
275
  FMRB_UnknownModRefBehavior =
276
      FMRL_Anywhere | static_cast<int>(ModRefInfo::ModRef)
277
};
278
279
// Wrapper method strips bits significant only in FunctionModRefBehavior,
280
// to obtain a valid ModRefInfo. The benefit of using the wrapper is that if
281
// ModRefInfo enum changes, the wrapper can be updated to & with the new enum
282
// entry with all bits set to 1.
283
LLVM_NODISCARD inline ModRefInfo
284
26.4M
createModRefInfo(const FunctionModRefBehavior FMRB) {
285
26.4M
  return ModRefInfo(FMRB & static_cast<int>(ModRefInfo::ModRef));
286
26.4M
}
287
288
class AAResults {
289
public:
290
  // Make these results default constructable and movable. We have to spell
291
  // these out because MSVC won't synthesize them.
292
10.3M
  AAResults(const TargetLibraryInfo &TLI) : TLI(TLI) {}
293
  AAResults(AAResults &&Arg);
294
  ~AAResults();
295
296
  /// Register a specific AA result.
297
39.2M
  template <typename AAResultT> void addAAResult(AAResultT &AAResult) {
298
39.2M
    // FIXME: We should use a much lighter weight system than the usual
299
39.2M
    // polymorphic pattern because we don't own AAResult. It should
300
39.2M
    // ideally involve two pointers and no separate allocation.
301
39.2M
    AAs.emplace_back(new Model<AAResultT>(AAResult, *this));
302
39.2M
  }
void llvm::AAResults::addAAResult<llvm::AMDGPUAAResult>(llvm::AMDGPUAAResult&)
Line
Count
Source
297
169k
  template <typename AAResultT> void addAAResult(AAResultT &AAResult) {
298
169k
    // FIXME: We should use a much lighter weight system than the usual
299
169k
    // polymorphic pattern because we don't own AAResult. It should
300
169k
    // ideally involve two pointers and no separate allocation.
301
169k
    AAs.emplace_back(new Model<AAResultT>(AAResult, *this));
302
169k
  }
void llvm::AAResults::addAAResult<llvm::BasicAAResult>(llvm::BasicAAResult&)
Line
Count
Source
297
10.3M
  template <typename AAResultT> void addAAResult(AAResultT &AAResult) {
298
10.3M
    // FIXME: We should use a much lighter weight system than the usual
299
10.3M
    // polymorphic pattern because we don't own AAResult. It should
300
10.3M
    // ideally involve two pointers and no separate allocation.
301
10.3M
    AAs.emplace_back(new Model<AAResultT>(AAResult, *this));
302
10.3M
  }
void llvm::AAResults::addAAResult<llvm::ScopedNoAliasAAResult>(llvm::ScopedNoAliasAAResult&)
Line
Count
Source
297
10.3M
  template <typename AAResultT> void addAAResult(AAResultT &AAResult) {
298
10.3M
    // FIXME: We should use a much lighter weight system than the usual
299
10.3M
    // polymorphic pattern because we don't own AAResult. It should
300
10.3M
    // ideally involve two pointers and no separate allocation.
301
10.3M
    AAs.emplace_back(new Model<AAResultT>(AAResult, *this));
302
10.3M
  }
void llvm::AAResults::addAAResult<llvm::TypeBasedAAResult>(llvm::TypeBasedAAResult&)
Line
Count
Source
297
10.3M
  template <typename AAResultT> void addAAResult(AAResultT &AAResult) {
298
10.3M
    // FIXME: We should use a much lighter weight system than the usual
299
10.3M
    // polymorphic pattern because we don't own AAResult. It should
300
10.3M
    // ideally involve two pointers and no separate allocation.
301
10.3M
    AAs.emplace_back(new Model<AAResultT>(AAResult, *this));
302
10.3M
  }
void llvm::AAResults::addAAResult<llvm::objcarc::ObjCARCAAResult>(llvm::objcarc::ObjCARCAAResult&)
Line
Count
Source
297
1.37k
  template <typename AAResultT> void addAAResult(AAResultT &AAResult) {
298
1.37k
    // FIXME: We should use a much lighter weight system than the usual
299
1.37k
    // polymorphic pattern because we don't own AAResult. It should
300
1.37k
    // ideally involve two pointers and no separate allocation.
301
1.37k
    AAs.emplace_back(new Model<AAResultT>(AAResult, *this));
302
1.37k
  }
void llvm::AAResults::addAAResult<llvm::GlobalsAAResult>(llvm::GlobalsAAResult&)
Line
Count
Source
297
7.99M
  template <typename AAResultT> void addAAResult(AAResultT &AAResult) {
298
7.99M
    // FIXME: We should use a much lighter weight system than the usual
299
7.99M
    // polymorphic pattern because we don't own AAResult. It should
300
7.99M
    // ideally involve two pointers and no separate allocation.
301
7.99M
    AAs.emplace_back(new Model<AAResultT>(AAResult, *this));
302
7.99M
  }
void llvm::AAResults::addAAResult<llvm::SCEVAAResult>(llvm::SCEVAAResult&)
Line
Count
Source
297
13
  template <typename AAResultT> void addAAResult(AAResultT &AAResult) {
298
13
    // FIXME: We should use a much lighter weight system than the usual
299
13
    // polymorphic pattern because we don't own AAResult. It should
300
13
    // ideally involve two pointers and no separate allocation.
301
13
    AAs.emplace_back(new Model<AAResultT>(AAResult, *this));
302
13
  }
void llvm::AAResults::addAAResult<llvm::CFLAndersAAResult>(llvm::CFLAndersAAResult&)
Line
Count
Source
297
83
  template <typename AAResultT> void addAAResult(AAResultT &AAResult) {
298
83
    // FIXME: We should use a much lighter weight system than the usual
299
83
    // polymorphic pattern because we don't own AAResult. It should
300
83
    // ideally involve two pointers and no separate allocation.
301
83
    AAs.emplace_back(new Model<AAResultT>(AAResult, *this));
302
83
  }
void llvm::AAResults::addAAResult<llvm::CFLSteensAAResult>(llvm::CFLSteensAAResult&)
Line
Count
Source
297
106
  template <typename AAResultT> void addAAResult(AAResultT &AAResult) {
298
106
    // FIXME: We should use a much lighter weight system than the usual
299
106
    // polymorphic pattern because we don't own AAResult. It should
300
106
    // ideally involve two pointers and no separate allocation.
301
106
    AAs.emplace_back(new Model<AAResultT>(AAResult, *this));
302
106
  }
303
304
  /// Register a function analysis ID that the results aggregation depends on.
305
  ///
306
  /// This is used in the new pass manager to implement the invalidation logic
307
  /// where we must invalidate the results aggregation if any of our component
308
  /// analyses become invalid.
309
2.08k
  void addAADependencyID(AnalysisKey *ID) { AADeps.push_back(ID); }
310
311
  /// Handle invalidation events in the new pass manager.
312
  ///
313
  /// The aggregation is invalidated if any of the underlying analyses is
314
  /// invalidated.
315
  bool invalidate(Function &F, const PreservedAnalyses &PA,
316
                  FunctionAnalysisManager::Invalidator &Inv);
317
318
  //===--------------------------------------------------------------------===//
319
  /// \name Alias Queries
320
  /// @{
321
322
  /// The main low level interface to the alias analysis implementation.
323
  /// Returns an AliasResult indicating whether the two pointers are aliased to
324
  /// each other. This is the interface that must be implemented by specific
325
  /// alias analysis implementations.
326
  AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB);
327
328
  /// A convenience wrapper around the primary \c alias interface.
329
  AliasResult alias(const Value *V1, LocationSize V1Size, const Value *V2,
330
398k
                    LocationSize V2Size) {
331
398k
    return alias(MemoryLocation(V1, V1Size), MemoryLocation(V2, V2Size));
332
398k
  }
333
334
  /// A convenience wrapper around the primary \c alias interface.
335
815
  AliasResult alias(const Value *V1, const Value *V2) {
336
815
    return alias(V1, LocationSize::unknown(), V2, LocationSize::unknown());
337
815
  }
338
339
  /// A trivial helper function to check to see if the specified pointers are
340
  /// no-alias.
341
8.94k
  bool isNoAlias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
342
8.94k
    return alias(LocA, LocB) == NoAlias;
343
8.94k
  }
344
345
  /// A convenience wrapper around the \c isNoAlias helper interface.
346
  bool isNoAlias(const Value *V1, LocationSize V1Size, const Value *V2,
347
0
                 LocationSize V2Size) {
348
0
    return isNoAlias(MemoryLocation(V1, V1Size), MemoryLocation(V2, V2Size));
349
0
  }
350
351
  /// A convenience wrapper around the \c isNoAlias helper interface.
352
0
  bool isNoAlias(const Value *V1, const Value *V2) {
353
0
    return isNoAlias(MemoryLocation(V1), MemoryLocation(V2));
354
0
  }
355
356
  /// A trivial helper function to check to see if the specified pointers are
357
  /// must-alias.
358
350k
  bool isMustAlias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
359
350k
    return alias(LocA, LocB) == MustAlias;
360
350k
  }
361
362
  /// A convenience wrapper around the \c isMustAlias helper interface.
363
392k
  bool isMustAlias(const Value *V1, const Value *V2) {
364
392k
    return alias(V1, LocationSize::precise(1), V2, LocationSize::precise(1)) ==
365
392k
           MustAlias;
366
392k
  }
367
368
  /// Checks whether the given location points to constant memory, or if
369
  /// \p OrLocal is true whether it points to a local alloca.
370
  bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal = false);
371
372
  /// A convenience wrapper around the primary \c pointsToConstantMemory
373
  /// interface.
374
4.70M
  bool pointsToConstantMemory(const Value *P, bool OrLocal = false) {
375
4.70M
    return pointsToConstantMemory(MemoryLocation(P), OrLocal);
376
4.70M
  }
377
378
  /// @}
379
  //===--------------------------------------------------------------------===//
380
  /// \name Simple mod/ref information
381
  /// @{
382
383
  /// Get the ModRef info associated with a pointer argument of a call. The
384
  /// result's bits are set to indicate the allowed aliasing ModRef kinds. Note
385
  /// that these bits do not necessarily account for the overall behavior of
386
  /// the function, but rather only provide additional per-argument
387
  /// information. This never sets ModRefInfo::Must.
388
  ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx);
389
390
  /// Return the behavior of the given call site.
391
  FunctionModRefBehavior getModRefBehavior(const CallBase *Call);
392
393
  /// Return the behavior when calling the given function.
394
  FunctionModRefBehavior getModRefBehavior(const Function *F);
395
396
  /// Checks if the specified call is known to never read or write memory.
397
  ///
398
  /// Note that if the call only reads from known-constant memory, it is also
399
  /// legal to return true. Also, calls that unwind the stack are legal for
400
  /// this predicate.
401
  ///
402
  /// Many optimizations (such as CSE and LICM) can be performed on such calls
403
  /// without worrying about aliasing properties, and many calls have this
404
  /// property (e.g. calls to 'sin' and 'cos').
405
  ///
406
  /// This property corresponds to the GCC 'const' attribute.
407
1.75M
  bool doesNotAccessMemory(const CallBase *Call) {
408
1.75M
    return getModRefBehavior(Call) == FMRB_DoesNotAccessMemory;
409
1.75M
  }
410
411
  /// Checks if the specified function is known to never read or write memory.
412
  ///
413
  /// Note that if the function only reads from known-constant memory, it is
414
  /// also legal to return true. Also, function that unwind the stack are legal
415
  /// for this predicate.
416
  ///
417
  /// Many optimizations (such as CSE and LICM) can be performed on such calls
418
  /// to such functions without worrying about aliasing properties, and many
419
  /// functions have this property (e.g. 'sin' and 'cos').
420
  ///
421
  /// This property corresponds to the GCC 'const' attribute.
422
0
  bool doesNotAccessMemory(const Function *F) {
423
0
    return getModRefBehavior(F) == FMRB_DoesNotAccessMemory;
424
0
  }
425
426
  /// Checks if the specified call is known to only read from non-volatile
427
  /// memory (or not access memory at all).
428
  ///
429
  /// Calls that unwind the stack are legal for this predicate.
430
  ///
431
  /// This property allows many common optimizations to be performed in the
432
  /// absence of interfering store instructions, such as CSE of strlen calls.
433
  ///
434
  /// This property corresponds to the GCC 'pure' attribute.
435
1.53M
  bool onlyReadsMemory(const CallBase *Call) {
436
1.53M
    return onlyReadsMemory(getModRefBehavior(Call));
437
1.53M
  }
438
439
  /// Checks if the specified function is known to only read from non-volatile
440
  /// memory (or not access memory at all).
441
  ///
442
  /// Functions that unwind the stack are legal for this predicate.
443
  ///
444
  /// This property allows many common optimizations to be performed in the
445
  /// absence of interfering store instructions, such as CSE of strlen calls.
446
  ///
447
  /// This property corresponds to the GCC 'pure' attribute.
448
0
  bool onlyReadsMemory(const Function *F) {
449
0
    return onlyReadsMemory(getModRefBehavior(F));
450
0
  }
451
452
  /// Checks if functions with the specified behavior are known to only read
453
  /// from non-volatile memory (or not access memory at all).
454
12.0M
  static bool onlyReadsMemory(FunctionModRefBehavior MRB) {
455
12.0M
    return !isModSet(createModRefInfo(MRB));
456
12.0M
  }
457
458
  /// Checks if functions with the specified behavior are known to only write
459
  /// memory (or not access memory at all).
460
9.01M
  static bool doesNotReadMemory(FunctionModRefBehavior MRB) {
461
9.01M
    return !isRefSet(createModRefInfo(MRB));
462
9.01M
  }
463
464
  /// Checks if functions with the specified behavior are known to read and
465
  /// write at most from objects pointed to by their pointer-typed arguments
466
  /// (with arbitrary offsets).
467
10.0M
  static bool onlyAccessesArgPointees(FunctionModRefBehavior MRB) {
468
10.0M
    return !(MRB & FMRL_Anywhere & ~FMRL_ArgumentPointees);
469
10.0M
  }
470
471
  /// Checks if functions with the specified behavior are known to potentially
472
  /// read or write from objects pointed to be their pointer-typed arguments
473
  /// (with arbitrary offsets).
474
1.18M
  static bool doesAccessArgPointees(FunctionModRefBehavior MRB) {
475
1.18M
    return isModOrRefSet(createModRefInfo(MRB)) &&
476
1.18M
           (MRB & FMRL_ArgumentPointees);
477
1.18M
  }
478
479
  /// Checks if functions with the specified behavior are known to read and
480
  /// write at most from memory that is inaccessible from LLVM IR.
481
0
  static bool onlyAccessesInaccessibleMem(FunctionModRefBehavior MRB) {
482
0
    return !(MRB & FMRL_Anywhere & ~FMRL_InaccessibleMem);
483
0
  }
484
485
  /// Checks if functions with the specified behavior are known to potentially
486
  /// read or write from memory that is inaccessible from LLVM IR.
487
0
  static bool doesAccessInaccessibleMem(FunctionModRefBehavior MRB) {
488
0
    return isModOrRefSet(createModRefInfo(MRB)) && (MRB & FMRL_InaccessibleMem);
489
0
  }
490
491
  /// Checks if functions with the specified behavior are known to read and
492
  /// write at most from memory that is inaccessible from LLVM IR or objects
493
  /// pointed to by their pointer-typed arguments (with arbitrary offsets).
494
6.64M
  static bool onlyAccessesInaccessibleOrArgMem(FunctionModRefBehavior MRB) {
495
6.64M
    return !(MRB & FMRL_Anywhere &
496
6.64M
             ~(FMRL_InaccessibleMem | FMRL_ArgumentPointees));
497
6.64M
  }
498
499
  /// getModRefInfo (for call sites) - Return information about whether
500
  /// a particular call site modifies or reads the specified memory location.
501
  ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc);
502
503
  /// getModRefInfo (for call sites) - A convenience wrapper.
504
  ModRefInfo getModRefInfo(const CallBase *Call, const Value *P,
505
180k
                           LocationSize Size) {
506
180k
    return getModRefInfo(Call, MemoryLocation(P, Size));
507
180k
  }
508
509
  /// getModRefInfo (for loads) - Return information about whether
510
  /// a particular load modifies or reads the specified memory location.
511
  ModRefInfo getModRefInfo(const LoadInst *L, const MemoryLocation &Loc);
512
513
  /// getModRefInfo (for loads) - A convenience wrapper.
514
  ModRefInfo getModRefInfo(const LoadInst *L, const Value *P,
515
0
                           LocationSize Size) {
516
0
    return getModRefInfo(L, MemoryLocation(P, Size));
517
0
  }
518
519
  /// getModRefInfo (for stores) - Return information about whether
520
  /// a particular store modifies or reads the specified memory location.
521
  ModRefInfo getModRefInfo(const StoreInst *S, const MemoryLocation &Loc);
522
523
  /// getModRefInfo (for stores) - A convenience wrapper.
524
  ModRefInfo getModRefInfo(const StoreInst *S, const Value *P,
525
2.79M
                           LocationSize Size) {
526
2.79M
    return getModRefInfo(S, MemoryLocation(P, Size));
527
2.79M
  }
528
529
  /// getModRefInfo (for fences) - Return information about whether
530
  /// a particular store modifies or reads the specified memory location.
531
  ModRefInfo getModRefInfo(const FenceInst *S, const MemoryLocation &Loc);
532
533
  /// getModRefInfo (for fences) - A convenience wrapper.
534
  ModRefInfo getModRefInfo(const FenceInst *S, const Value *P,
535
0
                           LocationSize Size) {
536
0
    return getModRefInfo(S, MemoryLocation(P, Size));
537
0
  }
538
539
  /// getModRefInfo (for cmpxchges) - Return information about whether
540
  /// a particular cmpxchg modifies or reads the specified memory location.
541
  ModRefInfo getModRefInfo(const AtomicCmpXchgInst *CX,
542
                           const MemoryLocation &Loc);
543
544
  /// getModRefInfo (for cmpxchges) - A convenience wrapper.
545
  ModRefInfo getModRefInfo(const AtomicCmpXchgInst *CX, const Value *P,
546
0
                           LocationSize Size) {
547
0
    return getModRefInfo(CX, MemoryLocation(P, Size));
548
0
  }
549
550
  /// getModRefInfo (for atomicrmws) - Return information about whether
551
  /// a particular atomicrmw modifies or reads the specified memory location.
552
  ModRefInfo getModRefInfo(const AtomicRMWInst *RMW, const MemoryLocation &Loc);
553
554
  /// getModRefInfo (for atomicrmws) - A convenience wrapper.
555
  ModRefInfo getModRefInfo(const AtomicRMWInst *RMW, const Value *P,
556
0
                           LocationSize Size) {
557
0
    return getModRefInfo(RMW, MemoryLocation(P, Size));
558
0
  }
559
560
  /// getModRefInfo (for va_args) - Return information about whether
561
  /// a particular va_arg modifies or reads the specified memory location.
562
  ModRefInfo getModRefInfo(const VAArgInst *I, const MemoryLocation &Loc);
563
564
  /// getModRefInfo (for va_args) - A convenience wrapper.
565
  ModRefInfo getModRefInfo(const VAArgInst *I, const Value *P,
566
0
                           LocationSize Size) {
567
0
    return getModRefInfo(I, MemoryLocation(P, Size));
568
0
  }
569
570
  /// getModRefInfo (for catchpads) - Return information about whether
571
  /// a particular catchpad modifies or reads the specified memory location.
572
  ModRefInfo getModRefInfo(const CatchPadInst *I, const MemoryLocation &Loc);
573
574
  /// getModRefInfo (for catchpads) - A convenience wrapper.
575
  ModRefInfo getModRefInfo(const CatchPadInst *I, const Value *P,
576
0
                           LocationSize Size) {
577
0
    return getModRefInfo(I, MemoryLocation(P, Size));
578
0
  }
579
580
  /// getModRefInfo (for catchrets) - Return information about whether
581
  /// a particular catchret modifies or reads the specified memory location.
582
  ModRefInfo getModRefInfo(const CatchReturnInst *I, const MemoryLocation &Loc);
583
584
  /// getModRefInfo (for catchrets) - A convenience wrapper.
585
  ModRefInfo getModRefInfo(const CatchReturnInst *I, const Value *P,
586
0
                           LocationSize Size) {
587
0
    return getModRefInfo(I, MemoryLocation(P, Size));
588
0
  }
589
590
  /// Check whether or not an instruction may read or write the optionally
591
  /// specified memory location.
592
  ///
593
  ///
594
  /// An instruction that doesn't read or write memory may be trivially LICM'd
595
  /// for example.
596
  ///
597
  /// For function calls, this delegates to the alias-analysis specific
598
  /// call-site mod-ref behavior queries. Otherwise it delegates to the specific
599
  /// helpers above.
600
  ModRefInfo getModRefInfo(const Instruction *I,
601
78.0M
                           const Optional<MemoryLocation> &OptLoc) {
602
78.0M
    if (OptLoc == None) {
603
26.4M
      if (const auto *Call = dyn_cast<CallBase>(I)) {
604
3.38M
        return createModRefInfo(getModRefBehavior(Call));
605
3.38M
      }
606
74.7M
    }
607
74.7M
608
74.7M
    const MemoryLocation &Loc = OptLoc.getValueOr(MemoryLocation());
609
74.7M
610
74.7M
    switch (I->getOpcode()) {
611
74.7M
    
case Instruction::VAArg: return getModRefInfo((const VAArgInst*)I, Loc)1.11k
;
612
74.7M
    
case Instruction::Load: return getModRefInfo((const LoadInst*)I, Loc)3.10M
;
613
74.7M
    
case Instruction::Store: return getModRefInfo((const StoreInst*)I, Loc)7.35M
;
614
74.7M
    
case Instruction::Fence: return getModRefInfo((const FenceInst*)I, Loc)36.5k
;
615
74.7M
    case Instruction::AtomicCmpXchg:
616
27.8k
      return getModRefInfo((const AtomicCmpXchgInst*)I, Loc);
617
74.7M
    case Instruction::AtomicRMW:
618
114k
      return getModRefInfo((const AtomicRMWInst*)I, Loc);
619
74.7M
    
case Instruction::Call: return getModRefInfo((const CallInst*)I, Loc)7.91M
;
620
74.7M
    
case Instruction::Invoke: return getModRefInfo((const InvokeInst*)I,Loc)274k
;
621
74.7M
    case Instruction::CatchPad:
622
20
      return getModRefInfo((const CatchPadInst *)I, Loc);
623
74.7M
    case Instruction::CatchRet:
624
29
      return getModRefInfo((const CatchReturnInst *)I, Loc);
625
74.7M
    default:
626
55.8M
      return ModRefInfo::NoModRef;
627
74.7M
    }
628
74.7M
  }
629
630
  /// A convenience wrapper for constructing the memory location.
631
  ModRefInfo getModRefInfo(const Instruction *I, const Value *P,
632
3.39M
                           LocationSize Size) {
633
3.39M
    return getModRefInfo(I, MemoryLocation(P, Size));
634
3.39M
  }
635
636
  /// Return information about whether a call and an instruction may refer to
637
  /// the same memory locations.
638
  ModRefInfo getModRefInfo(Instruction *I, const CallBase *Call);
639
640
  /// Return information about whether two call sites may refer to the same set
641
  /// of memory locations. See the AA documentation for details:
642
  ///   http://llvm.org/docs/AliasAnalysis.html#ModRefInfo
643
  ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2);
644
645
  /// Return information about whether a particular call site modifies
646
  /// or reads the specified memory location \p MemLoc before instruction \p I
647
  /// in a BasicBlock. An ordered basic block \p OBB can be used to speed up
648
  /// instruction ordering queries inside the BasicBlock containing \p I.
649
  /// Early exits in callCapturesBefore may lead to ModRefInfo::Must not being
650
  /// set.
651
  ModRefInfo callCapturesBefore(const Instruction *I,
652
                                const MemoryLocation &MemLoc, DominatorTree *DT,
653
                                OrderedBasicBlock *OBB = nullptr);
654
655
  /// A convenience wrapper to synthesize a memory location.
656
  ModRefInfo callCapturesBefore(const Instruction *I, const Value *P,
657
                                LocationSize Size, DominatorTree *DT,
658
4
                                OrderedBasicBlock *OBB = nullptr) {
659
4
    return callCapturesBefore(I, MemoryLocation(P, Size), DT, OBB);
660
4
  }
661
662
  /// @}
663
  //===--------------------------------------------------------------------===//
664
  /// \name Higher level methods for querying mod/ref information.
665
  /// @{
666
667
  /// Check if it is possible for execution of the specified basic block to
668
  /// modify the location Loc.
669
  bool canBasicBlockModify(const BasicBlock &BB, const MemoryLocation &Loc);
670
671
  /// A convenience wrapper synthesizing a memory location.
672
  bool canBasicBlockModify(const BasicBlock &BB, const Value *P,
673
0
                           LocationSize Size) {
674
0
    return canBasicBlockModify(BB, MemoryLocation(P, Size));
675
0
  }
676
677
  /// Check if it is possible for the execution of the specified instructions
678
  /// to mod\ref (according to the mode) the location Loc.
679
  ///
680
  /// The instructions to consider are all of the instructions in the range of
681
  /// [I1,I2] INCLUSIVE. I1 and I2 must be in the same basic block.
682
  bool canInstructionRangeModRef(const Instruction &I1, const Instruction &I2,
683
                                 const MemoryLocation &Loc,
684
                                 const ModRefInfo Mode);
685
686
  /// A convenience wrapper synthesizing a memory location.
687
  bool canInstructionRangeModRef(const Instruction &I1, const Instruction &I2,
688
                                 const Value *Ptr, LocationSize Size,
689
0
                                 const ModRefInfo Mode) {
690
0
    return canInstructionRangeModRef(I1, I2, MemoryLocation(Ptr, Size), Mode);
691
0
  }
692
693
private:
694
  class Concept;
695
696
  template <typename T> class Model;
697
698
  template <typename T> friend class AAResultBase;
699
700
  const TargetLibraryInfo &TLI;
701
702
  std::vector<std::unique_ptr<Concept>> AAs;
703
704
  std::vector<AnalysisKey *> AADeps;
705
};
706
707
/// Temporary typedef for legacy code that uses a generic \c AliasAnalysis
708
/// pointer or reference.
709
using AliasAnalysis = AAResults;
710
711
/// A private abstract base class describing the concept of an individual alias
712
/// analysis implementation.
713
///
714
/// This interface is implemented by any \c Model instantiation. It is also the
715
/// interface which a type used to instantiate the model must provide.
716
///
717
/// All of these methods model methods by the same name in the \c
718
/// AAResults class. Only differences and specifics to how the
719
/// implementations are called are documented here.
720
class AAResults::Concept {
721
public:
722
  virtual ~Concept() = 0;
723
724
  /// An update API used internally by the AAResults to provide
725
  /// a handle back to the top level aggregation.
726
  virtual void setAAResults(AAResults *NewAAR) = 0;
727
728
  //===--------------------------------------------------------------------===//
729
  /// \name Alias Queries
730
  /// @{
731
732
  /// The main low level interface to the alias analysis implementation.
733
  /// Returns an AliasResult indicating whether the two pointers are aliased to
734
  /// each other. This is the interface that must be implemented by specific
735
  /// alias analysis implementations.
736
  virtual AliasResult alias(const MemoryLocation &LocA,
737
                            const MemoryLocation &LocB) = 0;
738
739
  /// Checks whether the given location points to constant memory, or if
740
  /// \p OrLocal is true whether it points to a local alloca.
741
  virtual bool pointsToConstantMemory(const MemoryLocation &Loc,
742
                                      bool OrLocal) = 0;
743
744
  /// @}
745
  //===--------------------------------------------------------------------===//
746
  /// \name Simple mod/ref information
747
  /// @{
748
749
  /// Get the ModRef info associated with a pointer argument of a callsite. The
750
  /// result's bits are set to indicate the allowed aliasing ModRef kinds. Note
751
  /// that these bits do not necessarily account for the overall behavior of
752
  /// the function, but rather only provide additional per-argument
753
  /// information.
754
  virtual ModRefInfo getArgModRefInfo(const CallBase *Call,
755
                                      unsigned ArgIdx) = 0;
756
757
  /// Return the behavior of the given call site.
758
  virtual FunctionModRefBehavior getModRefBehavior(const CallBase *Call) = 0;
759
760
  /// Return the behavior when calling the given function.
761
  virtual FunctionModRefBehavior getModRefBehavior(const Function *F) = 0;
762
763
  /// getModRefInfo (for call sites) - Return information about whether
764
  /// a particular call site modifies or reads the specified memory location.
765
  virtual ModRefInfo getModRefInfo(const CallBase *Call,
766
                                   const MemoryLocation &Loc) = 0;
767
768
  /// Return information about whether two call sites may refer to the same set
769
  /// of memory locations. See the AA documentation for details:
770
  ///   http://llvm.org/docs/AliasAnalysis.html#ModRefInfo
771
  virtual ModRefInfo getModRefInfo(const CallBase *Call1,
772
                                   const CallBase *Call2) = 0;
773
774
  /// @}
775
};
776
777
/// A private class template which derives from \c Concept and wraps some other
778
/// type.
779
///
780
/// This models the concept by directly forwarding each interface point to the
781
/// wrapped type which must implement a compatible interface. This provides
782
/// a type erased binding.
783
template <typename AAResultT> class AAResults::Model final : public Concept {
784
  AAResultT &Result;
785
786
public:
787
39.2M
  explicit Model(AAResultT &Result, AAResults &AAR) : Result(Result) {
788
39.2M
    Result.setAAResults(&AAR);
789
39.2M
  }
llvm::AAResults::Model<llvm::AMDGPUAAResult>::Model(llvm::AMDGPUAAResult&, llvm::AAResults&)
Line
Count
Source
787
169k
  explicit Model(AAResultT &Result, AAResults &AAR) : Result(Result) {
788
169k
    Result.setAAResults(&AAR);
789
169k
  }
llvm::AAResults::Model<llvm::BasicAAResult>::Model(llvm::BasicAAResult&, llvm::AAResults&)
Line
Count
Source
787
10.3M
  explicit Model(AAResultT &Result, AAResults &AAR) : Result(Result) {
788
10.3M
    Result.setAAResults(&AAR);
789
10.3M
  }
llvm::AAResults::Model<llvm::ScopedNoAliasAAResult>::Model(llvm::ScopedNoAliasAAResult&, llvm::AAResults&)
Line
Count
Source
787
10.3M
  explicit Model(AAResultT &Result, AAResults &AAR) : Result(Result) {
788
10.3M
    Result.setAAResults(&AAR);
789
10.3M
  }
llvm::AAResults::Model<llvm::TypeBasedAAResult>::Model(llvm::TypeBasedAAResult&, llvm::AAResults&)
Line
Count
Source
787
10.3M
  explicit Model(AAResultT &Result, AAResults &AAR) : Result(Result) {
788
10.3M
    Result.setAAResults(&AAR);
789
10.3M
  }
llvm::AAResults::Model<llvm::objcarc::ObjCARCAAResult>::Model(llvm::objcarc::ObjCARCAAResult&, llvm::AAResults&)
Line
Count
Source
787
1.37k
  explicit Model(AAResultT &Result, AAResults &AAR) : Result(Result) {
788
1.37k
    Result.setAAResults(&AAR);
789
1.37k
  }
llvm::AAResults::Model<llvm::GlobalsAAResult>::Model(llvm::GlobalsAAResult&, llvm::AAResults&)
Line
Count
Source
787
7.99M
  explicit Model(AAResultT &Result, AAResults &AAR) : Result(Result) {
788
7.99M
    Result.setAAResults(&AAR);
789
7.99M
  }
llvm::AAResults::Model<llvm::SCEVAAResult>::Model(llvm::SCEVAAResult&, llvm::AAResults&)
Line
Count
Source
787
13
  explicit Model(AAResultT &Result, AAResults &AAR) : Result(Result) {
788
13
    Result.setAAResults(&AAR);
789
13
  }
llvm::AAResults::Model<llvm::CFLAndersAAResult>::Model(llvm::CFLAndersAAResult&, llvm::AAResults&)
Line
Count
Source
787
83
  explicit Model(AAResultT &Result, AAResults &AAR) : Result(Result) {
788
83
    Result.setAAResults(&AAR);
789
83
  }
llvm::AAResults::Model<llvm::CFLSteensAAResult>::Model(llvm::CFLSteensAAResult&, llvm::AAResults&)
Line
Count
Source
787
106
  explicit Model(AAResultT &Result, AAResults &AAR) : Result(Result) {
788
106
    Result.setAAResults(&AAR);
789
106
  }
790
39.2M
  ~Model() override = default;
llvm::AAResults::Model<llvm::AMDGPUAAResult>::~Model()
Line
Count
Source
790
169k
  ~Model() override = default;
llvm::AAResults::Model<llvm::BasicAAResult>::~Model()
Line
Count
Source
790
10.3M
  ~Model() override = default;
llvm::AAResults::Model<llvm::ScopedNoAliasAAResult>::~Model()
Line
Count
Source
790
10.3M
  ~Model() override = default;
llvm::AAResults::Model<llvm::TypeBasedAAResult>::~Model()
Line
Count
Source
790
10.3M
  ~Model() override = default;
llvm::AAResults::Model<llvm::objcarc::ObjCARCAAResult>::~Model()
Line
Count
Source
790
1.37k
  ~Model() override = default;
llvm::AAResults::Model<llvm::GlobalsAAResult>::~Model()
Line
Count
Source
790
7.99M
  ~Model() override = default;
llvm::AAResults::Model<llvm::SCEVAAResult>::~Model()
Line
Count
Source
790
13
  ~Model() override = default;
llvm::AAResults::Model<llvm::CFLAndersAAResult>::~Model()
Line
Count
Source
790
83
  ~Model() override = default;
llvm::AAResults::Model<llvm::CFLSteensAAResult>::~Model()
Line
Count
Source
790
106
  ~Model() override = default;
791
792
4.53M
  void setAAResults(AAResults *NewAAR) override { Result.setAAResults(NewAAR); }
Unexecuted instantiation: llvm::AAResults::Model<llvm::AMDGPUAAResult>::setAAResults(llvm::AAResults*)
llvm::AAResults::Model<llvm::BasicAAResult>::setAAResults(llvm::AAResults*)
Line
Count
Source
792
1.15M
  void setAAResults(AAResults *NewAAR) override { Result.setAAResults(NewAAR); }
llvm::AAResults::Model<llvm::ScopedNoAliasAAResult>::setAAResults(llvm::AAResults*)
Line
Count
Source
792
1.12M
  void setAAResults(AAResults *NewAAR) override { Result.setAAResults(NewAAR); }
llvm::AAResults::Model<llvm::TypeBasedAAResult>::setAAResults(llvm::AAResults*)
Line
Count
Source
792
1.12M
  void setAAResults(AAResults *NewAAR) override { Result.setAAResults(NewAAR); }
llvm::AAResults::Model<llvm::objcarc::ObjCARCAAResult>::setAAResults(llvm::AAResults*)
Line
Count
Source
792
113
  void setAAResults(AAResults *NewAAR) override { Result.setAAResults(NewAAR); }
llvm::AAResults::Model<llvm::GlobalsAAResult>::setAAResults(llvm::AAResults*)
Line
Count
Source
792
1.12M
  void setAAResults(AAResults *NewAAR) override { Result.setAAResults(NewAAR); }
llvm::AAResults::Model<llvm::SCEVAAResult>::setAAResults(llvm::AAResults*)
Line
Count
Source
792
12
  void setAAResults(AAResults *NewAAR) override { Result.setAAResults(NewAAR); }
llvm::AAResults::Model<llvm::CFLAndersAAResult>::setAAResults(llvm::AAResults*)
Line
Count
Source
792
82
  void setAAResults(AAResults *NewAAR) override { Result.setAAResults(NewAAR); }
llvm::AAResults::Model<llvm::CFLSteensAAResult>::setAAResults(llvm::AAResults*)
Line
Count
Source
792
84
  void setAAResults(AAResults *NewAAR) override { Result.setAAResults(NewAAR); }
793
794
  AliasResult alias(const MemoryLocation &LocA,
795
207M
                    const MemoryLocation &LocB) override {
796
207M
    return Result.alias(LocA, LocB);
797
207M
  }
llvm::AAResults::Model<llvm::AMDGPUAAResult>::alias(llvm::MemoryLocation const&, llvm::MemoryLocation const&)
Line
Count
Source
795
85.4k
                    const MemoryLocation &LocB) override {
796
85.4k
    return Result.alias(LocA, LocB);
797
85.4k
  }
llvm::AAResults::Model<llvm::BasicAAResult>::alias(llvm::MemoryLocation const&, llvm::MemoryLocation const&)
Line
Count
Source
795
84.5M
                    const MemoryLocation &LocB) override {
796
84.5M
    return Result.alias(LocA, LocB);
797
84.5M
  }
llvm::AAResults::Model<llvm::ScopedNoAliasAAResult>::alias(llvm::MemoryLocation const&, llvm::MemoryLocation const&)
Line
Count
Source
795
45.6M
                    const MemoryLocation &LocB) override {
796
45.6M
    return Result.alias(LocA, LocB);
797
45.6M
  }
llvm::AAResults::Model<llvm::TypeBasedAAResult>::alias(llvm::MemoryLocation const&, llvm::MemoryLocation const&)
Line
Count
Source
795
45.4M
                    const MemoryLocation &LocB) override {
796
45.4M
    return Result.alias(LocA, LocB);
797
45.4M
  }
llvm::AAResults::Model<llvm::objcarc::ObjCARCAAResult>::alias(llvm::MemoryLocation const&, llvm::MemoryLocation const&)
Line
Count
Source
795
1.43k
                    const MemoryLocation &LocB) override {
796
1.43k
    return Result.alias(LocA, LocB);
797
1.43k
  }
llvm::AAResults::Model<llvm::GlobalsAAResult>::alias(llvm::MemoryLocation const&, llvm::MemoryLocation const&)
Line
Count
Source
795
32.1M
                    const MemoryLocation &LocB) override {
796
32.1M
    return Result.alias(LocA, LocB);
797
32.1M
  }
llvm::AAResults::Model<llvm::SCEVAAResult>::alias(llvm::MemoryLocation const&, llvm::MemoryLocation const&)
Line
Count
Source
795
124
                    const MemoryLocation &LocB) override {
796
124
    return Result.alias(LocA, LocB);
797
124
  }
llvm::AAResults::Model<llvm::CFLAndersAAResult>::alias(llvm::MemoryLocation const&, llvm::MemoryLocation const&)
Line
Count
Source
795
665
                    const MemoryLocation &LocB) override {
796
665
    return Result.alias(LocA, LocB);
797
665
  }
llvm::AAResults::Model<llvm::CFLSteensAAResult>::alias(llvm::MemoryLocation const&, llvm::MemoryLocation const&)
Line
Count
Source
795
2.80k
                    const MemoryLocation &LocB) override {
796
2.80k
    return Result.alias(LocA, LocB);
797
2.80k
  }
798
799
  bool pointsToConstantMemory(const MemoryLocation &Loc,
800
79.8M
                              bool OrLocal) override {
801
79.8M
    return Result.pointsToConstantMemory(Loc, OrLocal);
802
79.8M
  }
llvm::AAResults::Model<llvm::AMDGPUAAResult>::pointsToConstantMemory(llvm::MemoryLocation const&, bool)
Line
Count
Source
800
93.2k
                              bool OrLocal) override {
801
93.2k
    return Result.pointsToConstantMemory(Loc, OrLocal);
802
93.2k
  }
llvm::AAResults::Model<llvm::BasicAAResult>::pointsToConstantMemory(llvm::MemoryLocation const&, bool)
Line
Count
Source
800
22.9M
                              bool OrLocal) override {
801
22.9M
    return Result.pointsToConstantMemory(Loc, OrLocal);
802
22.9M
  }
llvm::AAResults::Model<llvm::ScopedNoAliasAAResult>::pointsToConstantMemory(llvm::MemoryLocation const&, bool)
Line
Count
Source
800
22.4M
                              bool OrLocal) override {
801
22.4M
    return Result.pointsToConstantMemory(Loc, OrLocal);
802
22.4M
  }
llvm::AAResults::Model<llvm::TypeBasedAAResult>::pointsToConstantMemory(llvm::MemoryLocation const&, bool)
Line
Count
Source
800
22.4M
                              bool OrLocal) override {
801
22.4M
    return Result.pointsToConstantMemory(Loc, OrLocal);
802
22.4M
  }
llvm::AAResults::Model<llvm::objcarc::ObjCARCAAResult>::pointsToConstantMemory(llvm::MemoryLocation const&, bool)
Line
Count
Source
800
2.11k
                              bool OrLocal) override {
801
2.11k
    return Result.pointsToConstantMemory(Loc, OrLocal);
802
2.11k
  }
llvm::AAResults::Model<llvm::GlobalsAAResult>::pointsToConstantMemory(llvm::MemoryLocation const&, bool)
Line
Count
Source
800
11.9M
                              bool OrLocal) override {
801
11.9M
    return Result.pointsToConstantMemory(Loc, OrLocal);
802
11.9M
  }
Unexecuted instantiation: llvm::AAResults::Model<llvm::SCEVAAResult>::pointsToConstantMemory(llvm::MemoryLocation const&, bool)
llvm::AAResults::Model<llvm::CFLAndersAAResult>::pointsToConstantMemory(llvm::MemoryLocation const&, bool)
Line
Count
Source
800
252
                              bool OrLocal) override {
801
252
    return Result.pointsToConstantMemory(Loc, OrLocal);
802
252
  }
llvm::AAResults::Model<llvm::CFLSteensAAResult>::pointsToConstantMemory(llvm::MemoryLocation const&, bool)
Line
Count
Source
800
298
                              bool OrLocal) override {
801
298
    return Result.pointsToConstantMemory(Loc, OrLocal);
802
298
  }
803
804
2.17M
  ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) override {
805
2.17M
    return Result.getArgModRefInfo(Call, ArgIdx);
806
2.17M
  }
llvm::AAResults::Model<llvm::AMDGPUAAResult>::getArgModRefInfo(llvm::CallBase const*, unsigned int)
Line
Count
Source
804
31
  ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) override {
805
31
    return Result.getArgModRefInfo(Call, ArgIdx);
806
31
  }
llvm::AAResults::Model<llvm::BasicAAResult>::getArgModRefInfo(llvm::CallBase const*, unsigned int)
Line
Count
Source
804
558k
  ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) override {
805
558k
    return Result.getArgModRefInfo(Call, ArgIdx);
806
558k
  }
llvm::AAResults::Model<llvm::ScopedNoAliasAAResult>::getArgModRefInfo(llvm::CallBase const*, unsigned int)
Line
Count
Source
804
557k
  ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) override {
805
557k
    return Result.getArgModRefInfo(Call, ArgIdx);
806
557k
  }
llvm::AAResults::Model<llvm::TypeBasedAAResult>::getArgModRefInfo(llvm::CallBase const*, unsigned int)
Line
Count
Source
804
557k
  ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) override {
805
557k
    return Result.getArgModRefInfo(Call, ArgIdx);
806
557k
  }
llvm::AAResults::Model<llvm::objcarc::ObjCARCAAResult>::getArgModRefInfo(llvm::CallBase const*, unsigned int)
Line
Count
Source
804
7
  ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) override {
805
7
    return Result.getArgModRefInfo(Call, ArgIdx);
806
7
  }
llvm::AAResults::Model<llvm::GlobalsAAResult>::getArgModRefInfo(llvm::CallBase const*, unsigned int)
Line
Count
Source
804
503k
  ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) override {
805
503k
    return Result.getArgModRefInfo(Call, ArgIdx);
806
503k
  }
Unexecuted instantiation: llvm::AAResults::Model<llvm::SCEVAAResult>::getArgModRefInfo(llvm::CallBase const*, unsigned int)
Unexecuted instantiation: llvm::AAResults::Model<llvm::CFLAndersAAResult>::getArgModRefInfo(llvm::CallBase const*, unsigned int)
Unexecuted instantiation: llvm::AAResults::Model<llvm::CFLSteensAAResult>::getArgModRefInfo(llvm::CallBase const*, unsigned int)
807
808
66.9M
  FunctionModRefBehavior getModRefBehavior(const CallBase *Call) override {
809
66.9M
    return Result.getModRefBehavior(Call);
810
66.9M
  }
llvm::AAResults::Model<llvm::AMDGPUAAResult>::getModRefBehavior(llvm::CallBase const*)
Line
Count
Source
808
1.31k
  FunctionModRefBehavior getModRefBehavior(const CallBase *Call) override {
809
1.31k
    return Result.getModRefBehavior(Call);
810
1.31k
  }
llvm::AAResults::Model<llvm::BasicAAResult>::getModRefBehavior(llvm::CallBase const*)
Line
Count
Source
808
17.6M
  FunctionModRefBehavior getModRefBehavior(const CallBase *Call) override {
809
17.6M
    return Result.getModRefBehavior(Call);
810
17.6M
  }
llvm::AAResults::Model<llvm::ScopedNoAliasAAResult>::getModRefBehavior(llvm::CallBase const*)
Line
Count
Source
808
17.3M
  FunctionModRefBehavior getModRefBehavior(const CallBase *Call) override {
809
17.3M
    return Result.getModRefBehavior(Call);
810
17.3M
  }
llvm::AAResults::Model<llvm::TypeBasedAAResult>::getModRefBehavior(llvm::CallBase const*)
Line
Count
Source
808
17.3M
  FunctionModRefBehavior getModRefBehavior(const CallBase *Call) override {
809
17.3M
    return Result.getModRefBehavior(Call);
810
17.3M
  }
llvm::AAResults::Model<llvm::objcarc::ObjCARCAAResult>::getModRefBehavior(llvm::CallBase const*)
Line
Count
Source
808
4.16k
  FunctionModRefBehavior getModRefBehavior(const CallBase *Call) override {
809
4.16k
    return Result.getModRefBehavior(Call);
810
4.16k
  }
llvm::AAResults::Model<llvm::GlobalsAAResult>::getModRefBehavior(llvm::CallBase const*)
Line
Count
Source
808
14.6M
  FunctionModRefBehavior getModRefBehavior(const CallBase *Call) override {
809
14.6M
    return Result.getModRefBehavior(Call);
810
14.6M
  }
Unexecuted instantiation: llvm::AAResults::Model<llvm::SCEVAAResult>::getModRefBehavior(llvm::CallBase const*)
llvm::AAResults::Model<llvm::CFLAndersAAResult>::getModRefBehavior(llvm::CallBase const*)
Line
Count
Source
808
284
  FunctionModRefBehavior getModRefBehavior(const CallBase *Call) override {
809
284
    return Result.getModRefBehavior(Call);
810
284
  }
llvm::AAResults::Model<llvm::CFLSteensAAResult>::getModRefBehavior(llvm::CallBase const*)
Line
Count
Source
808
359
  FunctionModRefBehavior getModRefBehavior(const CallBase *Call) override {
809
359
    return Result.getModRefBehavior(Call);
810
359
  }
811
812
65.1M
  FunctionModRefBehavior getModRefBehavior(const Function *F) override {
813
65.1M
    return Result.getModRefBehavior(F);
814
65.1M
  }
llvm::AAResults::Model<llvm::AMDGPUAAResult>::getModRefBehavior(llvm::Function const*)
Line
Count
Source
812
1.03k
  FunctionModRefBehavior getModRefBehavior(const Function *F) override {
813
1.03k
    return Result.getModRefBehavior(F);
814
1.03k
  }
llvm::AAResults::Model<llvm::BasicAAResult>::getModRefBehavior(llvm::Function const*)
Line
Count
Source
812
16.9M
  FunctionModRefBehavior getModRefBehavior(const Function *F) override {
813
16.9M
    return Result.getModRefBehavior(F);
814
16.9M
  }
llvm::AAResults::Model<llvm::ScopedNoAliasAAResult>::getModRefBehavior(llvm::Function const*)
Line
Count
Source
812
16.9M
  FunctionModRefBehavior getModRefBehavior(const Function *F) override {
813
16.9M
    return Result.getModRefBehavior(F);
814
16.9M
  }
llvm::AAResults::Model<llvm::TypeBasedAAResult>::getModRefBehavior(llvm::Function const*)
Line
Count
Source
812
16.9M
  FunctionModRefBehavior getModRefBehavior(const Function *F) override {
813
16.9M
    return Result.getModRefBehavior(F);
814
16.9M
  }
llvm::AAResults::Model<llvm::objcarc::ObjCARCAAResult>::getModRefBehavior(llvm::Function const*)
Line
Count
Source
812
3.65k
  FunctionModRefBehavior getModRefBehavior(const Function *F) override {
813
3.65k
    return Result.getModRefBehavior(F);
814
3.65k
  }
llvm::AAResults::Model<llvm::GlobalsAAResult>::getModRefBehavior(llvm::Function const*)
Line
Count
Source
812
14.3M
  FunctionModRefBehavior getModRefBehavior(const Function *F) override {
813
14.3M
    return Result.getModRefBehavior(F);
814
14.3M
  }
Unexecuted instantiation: llvm::AAResults::Model<llvm::SCEVAAResult>::getModRefBehavior(llvm::Function const*)
Unexecuted instantiation: llvm::AAResults::Model<llvm::CFLAndersAAResult>::getModRefBehavior(llvm::Function const*)
Unexecuted instantiation: llvm::AAResults::Model<llvm::CFLSteensAAResult>::getModRefBehavior(llvm::Function const*)
815
816
  ModRefInfo getModRefInfo(const CallBase *Call,
817
30.8M
                           const MemoryLocation &Loc) override {
818
30.8M
    return Result.getModRefInfo(Call, Loc);
819
30.8M
  }
llvm::AAResults::Model<llvm::AMDGPUAAResult>::getModRefInfo(llvm::CallBase const*, llvm::MemoryLocation const&)
Line
Count
Source
817
12.8k
                           const MemoryLocation &Loc) override {
818
12.8k
    return Result.getModRefInfo(Call, Loc);
819
12.8k
  }
llvm::AAResults::Model<llvm::BasicAAResult>::getModRefInfo(llvm::CallBase const*, llvm::MemoryLocation const&)
Line
Count
Source
817
8.54M
                           const MemoryLocation &Loc) override {
818
8.54M
    return Result.getModRefInfo(Call, Loc);
819
8.54M
  }
llvm::AAResults::Model<llvm::ScopedNoAliasAAResult>::getModRefInfo(llvm::CallBase const*, llvm::MemoryLocation const&)
Line
Count
Source
817
7.86M
                           const MemoryLocation &Loc) override {
818
7.86M
    return Result.getModRefInfo(Call, Loc);
819
7.86M
  }
llvm::AAResults::Model<llvm::TypeBasedAAResult>::getModRefInfo(llvm::CallBase const*, llvm::MemoryLocation const&)
Line
Count
Source
817
7.85M
                           const MemoryLocation &Loc) override {
818
7.85M
    return Result.getModRefInfo(Call, Loc);
819
7.85M
  }
llvm::AAResults::Model<llvm::objcarc::ObjCARCAAResult>::getModRefInfo(llvm::CallBase const*, llvm::MemoryLocation const&)
Line
Count
Source
817
663
                           const MemoryLocation &Loc) override {
818
663
    return Result.getModRefInfo(Call, Loc);
819
663
  }
llvm::AAResults::Model<llvm::GlobalsAAResult>::getModRefInfo(llvm::CallBase const*, llvm::MemoryLocation const&)
Line
Count
Source
817
6.60M
                           const MemoryLocation &Loc) override {
818
6.60M
    return Result.getModRefInfo(Call, Loc);
819
6.60M
  }
Unexecuted instantiation: llvm::AAResults::Model<llvm::SCEVAAResult>::getModRefInfo(llvm::CallBase const*, llvm::MemoryLocation const&)
llvm::AAResults::Model<llvm::CFLAndersAAResult>::getModRefInfo(llvm::CallBase const*, llvm::MemoryLocation const&)
Line
Count
Source
817
252
                           const MemoryLocation &Loc) override {
818
252
    return Result.getModRefInfo(Call, Loc);
819
252
  }
llvm::AAResults::Model<llvm::CFLSteensAAResult>::getModRefInfo(llvm::CallBase const*, llvm::MemoryLocation const&)
Line
Count
Source
817
299
                           const MemoryLocation &Loc) override {
818
299
    return Result.getModRefInfo(Call, Loc);
819
299
  }
820
821
  ModRefInfo getModRefInfo(const CallBase *Call1,
822
3.30M
                           const CallBase *Call2) override {
823
3.30M
    return Result.getModRefInfo(Call1, Call2);
824
3.30M
  }
llvm::AAResults::Model<llvm::AMDGPUAAResult>::getModRefInfo(llvm::CallBase const*, llvm::CallBase const*)
Line
Count
Source
822
140
                           const CallBase *Call2) override {
823
140
    return Result.getModRefInfo(Call1, Call2);
824
140
  }
llvm::AAResults::Model<llvm::BasicAAResult>::getModRefInfo(llvm::CallBase const*, llvm::CallBase const*)
Line
Count
Source
822
829k
                           const CallBase *Call2) override {
823
829k
    return Result.getModRefInfo(Call1, Call2);
824
829k
  }
llvm::AAResults::Model<llvm::ScopedNoAliasAAResult>::getModRefInfo(llvm::CallBase const*, llvm::CallBase const*)
Line
Count
Source
822
828k
                           const CallBase *Call2) override {
823
828k
    return Result.getModRefInfo(Call1, Call2);
824
828k
  }
llvm::AAResults::Model<llvm::TypeBasedAAResult>::getModRefInfo(llvm::CallBase const*, llvm::CallBase const*)
Line
Count
Source
822
828k
                           const CallBase *Call2) override {
823
828k
    return Result.getModRefInfo(Call1, Call2);
824
828k
  }
llvm::AAResults::Model<llvm::objcarc::ObjCARCAAResult>::getModRefInfo(llvm::CallBase const*, llvm::CallBase const*)
Line
Count
Source
822
32
                           const CallBase *Call2) override {
823
32
    return Result.getModRefInfo(Call1, Call2);
824
32
  }
llvm::AAResults::Model<llvm::GlobalsAAResult>::getModRefInfo(llvm::CallBase const*, llvm::CallBase const*)
Line
Count
Source
822
819k
                           const CallBase *Call2) override {
823
819k
    return Result.getModRefInfo(Call1, Call2);
824
819k
  }
Unexecuted instantiation: llvm::AAResults::Model<llvm::SCEVAAResult>::getModRefInfo(llvm::CallBase const*, llvm::CallBase const*)
llvm::AAResults::Model<llvm::CFLAndersAAResult>::getModRefInfo(llvm::CallBase const*, llvm::CallBase const*)
Line
Count
Source
822
16
                           const CallBase *Call2) override {
823
16
    return Result.getModRefInfo(Call1, Call2);
824
16
  }
llvm::AAResults::Model<llvm::CFLSteensAAResult>::getModRefInfo(llvm::CallBase const*, llvm::CallBase const*)
Line
Count
Source
822
30
                           const CallBase *Call2) override {
823
30
    return Result.getModRefInfo(Call1, Call2);
824
30
  }
825
};
826
827
/// A CRTP-driven "mixin" base class to help implement the function alias
828
/// analysis results concept.
829
///
830
/// Because of the nature of many alias analysis implementations, they often
831
/// only implement a subset of the interface. This base class will attempt to
832
/// implement the remaining portions of the interface in terms of simpler forms
833
/// of the interface where possible, and otherwise provide conservatively
834
/// correct fallback implementations.
835
///
836
/// Implementors of an alias analysis should derive from this CRTP, and then
837
/// override specific methods that they wish to customize. There is no need to
838
/// use virtual anywhere, the CRTP base class does static dispatch to the
839
/// derived type passed into it.
840
template <typename DerivedT> class AAResultBase {
841
  // Expose some parts of the interface only to the AAResults::Model
842
  // for wrapping. Specifically, this allows the model to call our
843
  // setAAResults method without exposing it as a fully public API.
844
  friend class AAResults::Model<DerivedT>;
845
846
  /// A pointer to the AAResults object that this AAResult is
847
  /// aggregated within. May be null if not aggregated.
848
  AAResults *AAR;
849
850
  /// Helper to dispatch calls back through the derived type.
851
55.9M
  DerivedT &derived() { return static_cast<DerivedT &>(*this); }
852
853
  /// A setter for the AAResults pointer, which is used to satisfy the
854
  /// AAResults::Model contract.
855
43.7M
  void setAAResults(AAResults *NewAAR) { AAR = NewAAR; }
llvm::AAResultBase<llvm::AMDGPUAAResult>::setAAResults(llvm::AAResults*)
Line
Count
Source
855
169k
  void setAAResults(AAResults *NewAAR) { AAR = NewAAR; }
llvm::AAResultBase<llvm::BasicAAResult>::setAAResults(llvm::AAResults*)
Line
Count
Source
855
11.5M
  void setAAResults(AAResults *NewAAR) { AAR = NewAAR; }
llvm::AAResultBase<llvm::ScopedNoAliasAAResult>::setAAResults(llvm::AAResults*)
Line
Count
Source
855
11.4M
  void setAAResults(AAResults *NewAAR) { AAR = NewAAR; }
llvm::AAResultBase<llvm::TypeBasedAAResult>::setAAResults(llvm::AAResults*)
Line
Count
Source
855
11.4M
  void setAAResults(AAResults *NewAAR) { AAR = NewAAR; }
llvm::AAResultBase<llvm::objcarc::ObjCARCAAResult>::setAAResults(llvm::AAResults*)
Line
Count
Source
855
1.48k
  void setAAResults(AAResults *NewAAR) { AAR = NewAAR; }
llvm::AAResultBase<llvm::GlobalsAAResult>::setAAResults(llvm::AAResults*)
Line
Count
Source
855
9.11M
  void setAAResults(AAResults *NewAAR) { AAR = NewAAR; }
llvm::AAResultBase<llvm::SCEVAAResult>::setAAResults(llvm::AAResults*)
Line
Count
Source
855
25
  void setAAResults(AAResults *NewAAR) { AAR = NewAAR; }
llvm::AAResultBase<llvm::CFLAndersAAResult>::setAAResults(llvm::AAResults*)
Line
Count
Source
855
165
  void setAAResults(AAResults *NewAAR) { AAR = NewAAR; }
llvm::AAResultBase<llvm::CFLSteensAAResult>::setAAResults(llvm::AAResults*)
Line
Count
Source
855
190
  void setAAResults(AAResults *NewAAR) { AAR = NewAAR; }
856
857
protected:
858
  /// This proxy class models a common pattern where we delegate to either the
859
  /// top-level \c AAResults aggregation if one is registered, or to the
860
  /// current result if none are registered.
861
  class AAResultsProxy {
862
    AAResults *AAR;
863
    DerivedT &CurrentResult;
864
865
  public:
866
    AAResultsProxy(AAResults *AAR, DerivedT &CurrentResult)
867
55.9M
        : AAR(AAR), CurrentResult(CurrentResult) {}
868
869
39.6M
    AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
870
39.6M
      return AAR ? 
AAR->alias(LocA, LocB)39.6M
:
CurrentResult.alias(LocA, LocB)2
;
871
39.6M
    }
872
873
    bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal) {
874
      return AAR ? AAR->pointsToConstantMemory(Loc, OrLocal)
875
                 : CurrentResult.pointsToConstantMemory(Loc, OrLocal);
876
    }
877
878
    ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) {
879
      return AAR ? AAR->getArgModRefInfo(Call, ArgIdx)
880
                 : CurrentResult.getArgModRefInfo(Call, ArgIdx);
881
    }
882
883
    FunctionModRefBehavior getModRefBehavior(const CallBase *Call) {
884
      return AAR ? AAR->getModRefBehavior(Call)
885
                 : CurrentResult.getModRefBehavior(Call);
886
    }
887
888
16.3M
    FunctionModRefBehavior getModRefBehavior(const Function *F) {
889
16.3M
      return AAR ? AAR->getModRefBehavior(F) : 
CurrentResult.getModRefBehavior(F)0
;
890
16.3M
    }
891
892
    ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc) {
893
      return AAR ? AAR->getModRefInfo(Call, Loc)
894
                 : CurrentResult.getModRefInfo(Call, Loc);
895
    }
896
897
    ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2) {
898
      return AAR ? AAR->getModRefInfo(Call1, Call2)
899
                 : CurrentResult.getModRefInfo(Call1, Call2);
900
    }
901
  };
902
903
  explicit AAResultBase() = default;
904
905
  // Provide all the copy and move constructors so that derived types aren't
906
  // constrained.
907
  AAResultBase(const AAResultBase &Arg) {}
908
1.15M
  AAResultBase(AAResultBase &&Arg) {}
llvm::AAResultBase<llvm::CFLAndersAAResult>::AAResultBase(llvm::AAResultBase<llvm::CFLAndersAAResult>&&)
Line
Count
Source
908
82
  AAResultBase(AAResultBase &&Arg) {}
llvm::AAResultBase<llvm::CFLSteensAAResult>::AAResultBase(llvm::AAResultBase<llvm::CFLSteensAAResult>&&)
Line
Count
Source
908
84
  AAResultBase(AAResultBase &&Arg) {}
llvm::AAResultBase<llvm::GlobalsAAResult>::AAResultBase(llvm::AAResultBase<llvm::GlobalsAAResult>&&)
Line
Count
Source
908
336
  AAResultBase(AAResultBase &&Arg) {}
llvm::AAResultBase<llvm::BasicAAResult>::AAResultBase(llvm::AAResultBase<llvm::BasicAAResult>&&)
Line
Count
Source
908
1.15M
  AAResultBase(AAResultBase &&Arg) {}
llvm::AAResultBase<llvm::SCEVAAResult>::AAResultBase(llvm::AAResultBase<llvm::SCEVAAResult>&&)
Line
Count
Source
908
12
  AAResultBase(AAResultBase &&Arg) {}
llvm::AAResultBase<llvm::ScopedNoAliasAAResult>::AAResultBase(llvm::AAResultBase<llvm::ScopedNoAliasAAResult>&&)
Line
Count
Source
908
438
  AAResultBase(AAResultBase &&Arg) {}
llvm::AAResultBase<llvm::TypeBasedAAResult>::AAResultBase(llvm::AAResultBase<llvm::TypeBasedAAResult>&&)
Line
Count
Source
908
496
  AAResultBase(AAResultBase &&Arg) {}
909
910
  /// Get a proxy for the best AA result set to query at this time.
911
  ///
912
  /// When this result is part of a larger aggregation, this will proxy to that
913
  /// aggregation. When this result is used in isolation, it will just delegate
914
  /// back to the derived class's implementation.
915
  ///
916
  /// Note that callers of this need to take considerable care to not cause
917
  /// performance problems when they use this routine, in the case of a large
918
  /// number of alias analyses being aggregated, it can be expensive to walk
919
  /// back across the chain.
920
55.9M
  AAResultsProxy getBestAAResults() { return AAResultsProxy(AAR, derived()); }
921
922
public:
923
113M
  AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
924
113M
    return MayAlias;
925
113M
  }
llvm::AAResultBase<llvm::AMDGPUAAResult>::alias(llvm::MemoryLocation const&, llvm::MemoryLocation const&)
Line
Count
Source
923
73.8k
  AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
924
73.8k
    return MayAlias;
925
73.8k
  }
llvm::AAResultBase<llvm::CFLSteensAAResult>::alias(llvm::MemoryLocation const&, llvm::MemoryLocation const&)
Line
Count
Source
923
2.43k
  AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
924
2.43k
    return MayAlias;
925
2.43k
  }
llvm::AAResultBase<llvm::CFLAndersAAResult>::alias(llvm::MemoryLocation const&, llvm::MemoryLocation const&)
Line
Count
Source
923
273
  AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
924
273
    return MayAlias;
925
273
  }
llvm::AAResultBase<llvm::GlobalsAAResult>::alias(llvm::MemoryLocation const&, llvm::MemoryLocation const&)
Line
Count
Source
923
31.9M
  AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
924
31.9M
    return MayAlias;
925
31.9M
  }
llvm::AAResultBase<llvm::objcarc::ObjCARCAAResult>::alias(llvm::MemoryLocation const&, llvm::MemoryLocation const&)
Line
Count
Source
923
1.60k
  AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
924
1.60k
    return MayAlias;
925
1.60k
  }
llvm::AAResultBase<llvm::SCEVAAResult>::alias(llvm::MemoryLocation const&, llvm::MemoryLocation const&)
Line
Count
Source
923
64
  AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
924
64
    return MayAlias;
925
64
  }
llvm::AAResultBase<llvm::TypeBasedAAResult>::alias(llvm::MemoryLocation const&, llvm::MemoryLocation const&)
Line
Count
Source
923
35.6M
  AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
924
35.6M
    return MayAlias;
925
35.6M
  }
llvm::AAResultBase<llvm::ScopedNoAliasAAResult>::alias(llvm::MemoryLocation const&, llvm::MemoryLocation const&)
Line
Count
Source
923
45.4M
  AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
924
45.4M
    return MayAlias;
925
45.4M
  }
926
927
79.2M
  bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal) {
928
79.2M
    return false;
929
79.2M
  }
llvm::AAResultBase<llvm::AMDGPUAAResult>::pointsToConstantMemory(llvm::MemoryLocation const&, bool)
Line
Count
Source
927
66.5k
  bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal) {
928
66.5k
    return false;
929
66.5k
  }
llvm::AAResultBase<llvm::ScopedNoAliasAAResult>::pointsToConstantMemory(llvm::MemoryLocation const&, bool)
Line
Count
Source
927
22.4M
  bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal) {
928
22.4M
    return false;
929
22.4M
  }
llvm::AAResultBase<llvm::GlobalsAAResult>::pointsToConstantMemory(llvm::MemoryLocation const&, bool)
Line
Count
Source
927
11.9M
  bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal) {
928
11.9M
    return false;
929
11.9M
  }
Unexecuted instantiation: llvm::AAResultBase<llvm::SCEVAAResult>::pointsToConstantMemory(llvm::MemoryLocation const&, bool)
llvm::AAResultBase<llvm::CFLAndersAAResult>::pointsToConstantMemory(llvm::MemoryLocation const&, bool)
Line
Count
Source
927
252
  bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal) {
928
252
    return false;
929
252
  }
llvm::AAResultBase<llvm::CFLSteensAAResult>::pointsToConstantMemory(llvm::MemoryLocation const&, bool)
Line
Count
Source
927
298
  bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal) {
928
298
    return false;
929
298
  }
llvm::AAResultBase<llvm::BasicAAResult>::pointsToConstantMemory(llvm::MemoryLocation const&, bool)
Line
Count
Source
927
22.4M
  bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal) {
928
22.4M
    return false;
929
22.4M
  }
llvm::AAResultBase<llvm::objcarc::ObjCARCAAResult>::pointsToConstantMemory(llvm::MemoryLocation const&, bool)
Line
Count
Source
927
2.85k
  bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal) {
928
2.85k
    return false;
929
2.85k
  }
llvm::AAResultBase<llvm::TypeBasedAAResult>::pointsToConstantMemory(llvm::MemoryLocation const&, bool)
Line
Count
Source
927
22.4M
  bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal) {
928
22.4M
    return false;
929
22.4M
  }
930
931
1.78M
  ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) {
932
1.78M
    return ModRefInfo::ModRef;
933
1.78M
  }
llvm::AAResultBase<llvm::AMDGPUAAResult>::getArgModRefInfo(llvm::CallBase const*, unsigned int)
Line
Count
Source
931
31
  ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) {
932
31
    return ModRefInfo::ModRef;
933
31
  }
llvm::AAResultBase<llvm::ScopedNoAliasAAResult>::getArgModRefInfo(llvm::CallBase const*, unsigned int)
Line
Count
Source
931
557k
  ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) {
932
557k
    return ModRefInfo::ModRef;
933
557k
  }
llvm::AAResultBase<llvm::TypeBasedAAResult>::getArgModRefInfo(llvm::CallBase const*, unsigned int)
Line
Count
Source
931
557k
  ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) {
932
557k
    return ModRefInfo::ModRef;
933
557k
  }
llvm::AAResultBase<llvm::objcarc::ObjCARCAAResult>::getArgModRefInfo(llvm::CallBase const*, unsigned int)
Line
Count
Source
931
7
  ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) {
932
7
    return ModRefInfo::ModRef;
933
7
  }
llvm::AAResultBase<llvm::GlobalsAAResult>::getArgModRefInfo(llvm::CallBase const*, unsigned int)
Line
Count
Source
931
503k
  ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) {
932
503k
    return ModRefInfo::ModRef;
933
503k
  }
Unexecuted instantiation: llvm::AAResultBase<llvm::SCEVAAResult>::getArgModRefInfo(llvm::CallBase const*, unsigned int)
Unexecuted instantiation: llvm::AAResultBase<llvm::CFLAndersAAResult>::getArgModRefInfo(llvm::CallBase const*, unsigned int)
Unexecuted instantiation: llvm::AAResultBase<llvm::CFLSteensAAResult>::getArgModRefInfo(llvm::CallBase const*, unsigned int)
llvm::AAResultBase<llvm::BasicAAResult>::getArgModRefInfo(llvm::CallBase const*, unsigned int)
Line
Count
Source
931
170k
  ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) {
932
170k
    return ModRefInfo::ModRef;
933
170k
  }
934
935
49.3M
  FunctionModRefBehavior getModRefBehavior(const CallBase *Call) {
936
49.3M
    return FMRB_UnknownModRefBehavior;
937
49.3M
  }
llvm::AAResultBase<llvm::AMDGPUAAResult>::getModRefBehavior(llvm::CallBase const*)
Line
Count
Source
935
1.31k
  FunctionModRefBehavior getModRefBehavior(const CallBase *Call) {
936
1.31k
    return FMRB_UnknownModRefBehavior;
937
1.31k
  }
llvm::AAResultBase<llvm::ScopedNoAliasAAResult>::getModRefBehavior(llvm::CallBase const*)
Line
Count
Source
935
17.3M
  FunctionModRefBehavior getModRefBehavior(const CallBase *Call) {
936
17.3M
    return FMRB_UnknownModRefBehavior;
937
17.3M
  }
llvm::AAResultBase<llvm::objcarc::ObjCARCAAResult>::getModRefBehavior(llvm::CallBase const*)
Line
Count
Source
935
4.16k
  FunctionModRefBehavior getModRefBehavior(const CallBase *Call) {
936
4.16k
    return FMRB_UnknownModRefBehavior;
937
4.16k
  }
Unexecuted instantiation: llvm::AAResultBase<llvm::SCEVAAResult>::getModRefBehavior(llvm::CallBase const*)
llvm::AAResultBase<llvm::CFLAndersAAResult>::getModRefBehavior(llvm::CallBase const*)
Line
Count
Source
935
284
  FunctionModRefBehavior getModRefBehavior(const CallBase *Call) {
936
284
    return FMRB_UnknownModRefBehavior;
937
284
  }
llvm::AAResultBase<llvm::CFLSteensAAResult>::getModRefBehavior(llvm::CallBase const*)
Line
Count
Source
935
359
  FunctionModRefBehavior getModRefBehavior(const CallBase *Call) {
936
359
    return FMRB_UnknownModRefBehavior;
937
359
  }
llvm::AAResultBase<llvm::GlobalsAAResult>::getModRefBehavior(llvm::CallBase const*)
Line
Count
Source
935
14.6M
  FunctionModRefBehavior getModRefBehavior(const CallBase *Call) {
936
14.6M
    return FMRB_UnknownModRefBehavior;
937
14.6M
  }
llvm::AAResultBase<llvm::TypeBasedAAResult>::getModRefBehavior(llvm::CallBase const*)
Line
Count
Source
935
17.3M
  FunctionModRefBehavior getModRefBehavior(const CallBase *Call) {
936
17.3M
    return FMRB_UnknownModRefBehavior;
937
17.3M
  }
938
939
48.1M
  FunctionModRefBehavior getModRefBehavior(const Function *F) {
940
48.1M
    return FMRB_UnknownModRefBehavior;
941
48.1M
  }
llvm::AAResultBase<llvm::AMDGPUAAResult>::getModRefBehavior(llvm::Function const*)
Line
Count
Source
939
1.03k
  FunctionModRefBehavior getModRefBehavior(const Function *F) {
940
1.03k
    return FMRB_UnknownModRefBehavior;
941
1.03k
  }
llvm::AAResultBase<llvm::ScopedNoAliasAAResult>::getModRefBehavior(llvm::Function const*)
Line
Count
Source
939
16.9M
  FunctionModRefBehavior getModRefBehavior(const Function *F) {
940
16.9M
    return FMRB_UnknownModRefBehavior;
941
16.9M
  }
Unexecuted instantiation: llvm::AAResultBase<llvm::SCEVAAResult>::getModRefBehavior(llvm::Function const*)
Unexecuted instantiation: llvm::AAResultBase<llvm::CFLAndersAAResult>::getModRefBehavior(llvm::Function const*)
Unexecuted instantiation: llvm::AAResultBase<llvm::CFLSteensAAResult>::getModRefBehavior(llvm::Function const*)
llvm::AAResultBase<llvm::GlobalsAAResult>::getModRefBehavior(llvm::Function const*)
Line
Count
Source
939
14.3M
  FunctionModRefBehavior getModRefBehavior(const Function *F) {
940
14.3M
    return FMRB_UnknownModRefBehavior;
941
14.3M
  }
llvm::AAResultBase<llvm::objcarc::ObjCARCAAResult>::getModRefBehavior(llvm::Function const*)
Line
Count
Source
939
3.65k
  FunctionModRefBehavior getModRefBehavior(const Function *F) {
940
3.65k
    return FMRB_UnknownModRefBehavior;
941
3.65k
  }
llvm::AAResultBase<llvm::TypeBasedAAResult>::getModRefBehavior(llvm::Function const*)
Line
Count
Source
939
16.9M
  FunctionModRefBehavior getModRefBehavior(const Function *F) {
940
16.9M
    return FMRB_UnknownModRefBehavior;
941
16.9M
  }
942
943
29.9M
  ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc) {
944
29.9M
    return ModRefInfo::ModRef;
945
29.9M
  }
llvm::AAResultBase<llvm::AMDGPUAAResult>::getModRefInfo(llvm::CallBase const*, llvm::MemoryLocation const&)
Line
Count
Source
943
12.8k
  ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc) {
944
12.8k
    return ModRefInfo::ModRef;
945
12.8k
  }
Unexecuted instantiation: llvm::AAResultBase<llvm::SCEVAAResult>::getModRefInfo(llvm::CallBase const*, llvm::MemoryLocation const&)
llvm::AAResultBase<llvm::CFLAndersAAResult>::getModRefInfo(llvm::CallBase const*, llvm::MemoryLocation const&)
Line
Count
Source
943
252
  ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc) {
944
252
    return ModRefInfo::ModRef;
945
252
  }
llvm::AAResultBase<llvm::CFLSteensAAResult>::getModRefInfo(llvm::CallBase const*, llvm::MemoryLocation const&)
Line
Count
Source
943
299
  ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc) {
944
299
    return ModRefInfo::ModRef;
945
299
  }
llvm::AAResultBase<llvm::BasicAAResult>::getModRefInfo(llvm::CallBase const*, llvm::MemoryLocation const&)
Line
Count
Source
943
7.68M
  ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc) {
944
7.68M
    return ModRefInfo::ModRef;
945
7.68M
  }
llvm::AAResultBase<llvm::GlobalsAAResult>::getModRefInfo(llvm::CallBase const*, llvm::MemoryLocation const&)
Line
Count
Source
943
6.59M
  ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc) {
944
6.59M
    return ModRefInfo::ModRef;
945
6.59M
  }
llvm::AAResultBase<llvm::objcarc::ObjCARCAAResult>::getModRefInfo(llvm::CallBase const*, llvm::MemoryLocation const&)
Line
Count
Source
943
543
  ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc) {
944
543
    return ModRefInfo::ModRef;
945
543
  }
llvm::AAResultBase<llvm::TypeBasedAAResult>::getModRefInfo(llvm::CallBase const*, llvm::MemoryLocation const&)
Line
Count
Source
943
7.84M
  ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc) {
944
7.84M
    return ModRefInfo::ModRef;
945
7.84M
  }
llvm::AAResultBase<llvm::ScopedNoAliasAAResult>::getModRefInfo(llvm::CallBase const*, llvm::MemoryLocation const&)
Line
Count
Source
943
7.85M
  ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc) {
944
7.85M
    return ModRefInfo::ModRef;
945
7.85M
  }
946
947
3.30M
  ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2) {
948
3.30M
    return ModRefInfo::ModRef;
949
3.30M
  }
llvm::AAResultBase<llvm::AMDGPUAAResult>::getModRefInfo(llvm::CallBase const*, llvm::CallBase const*)
Line
Count
Source
947
140
  ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2) {
948
140
    return ModRefInfo::ModRef;
949
140
  }
llvm::AAResultBase<llvm::objcarc::ObjCARCAAResult>::getModRefInfo(llvm::CallBase const*, llvm::CallBase const*)
Line
Count
Source
947
32
  ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2) {
948
32
    return ModRefInfo::ModRef;
949
32
  }
llvm::AAResultBase<llvm::GlobalsAAResult>::getModRefInfo(llvm::CallBase const*, llvm::CallBase const*)
Line
Count
Source
947
819k
  ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2) {
948
819k
    return ModRefInfo::ModRef;
949
819k
  }
Unexecuted instantiation: llvm::AAResultBase<llvm::SCEVAAResult>::getModRefInfo(llvm::CallBase const*, llvm::CallBase const*)
llvm::AAResultBase<llvm::CFLAndersAAResult>::getModRefInfo(llvm::CallBase const*, llvm::CallBase const*)
Line
Count
Source
947
16
  ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2) {
948
16
    return ModRefInfo::ModRef;
949
16
  }
llvm::AAResultBase<llvm::CFLSteensAAResult>::getModRefInfo(llvm::CallBase const*, llvm::CallBase const*)
Line
Count
Source
947
30
  ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2) {
948
30
    return ModRefInfo::ModRef;
949
30
  }
llvm::AAResultBase<llvm::BasicAAResult>::getModRefInfo(llvm::CallBase const*, llvm::CallBase const*)
Line
Count
Source
947
829k
  ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2) {
948
829k
    return ModRefInfo::ModRef;
949
829k
  }
llvm::AAResultBase<llvm::TypeBasedAAResult>::getModRefInfo(llvm::CallBase const*, llvm::CallBase const*)
Line
Count
Source
947
828k
  ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2) {
948
828k
    return ModRefInfo::ModRef;
949
828k
  }
llvm::AAResultBase<llvm::ScopedNoAliasAAResult>::getModRefInfo(llvm::CallBase const*, llvm::CallBase const*)
Line
Count
Source
947
828k
  ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2) {
948
828k
    return ModRefInfo::ModRef;
949
828k
  }
950
};
951
952
/// Return true if this pointer is returned by a noalias function.
953
bool isNoAliasCall(const Value *V);
954
955
/// Return true if this is an argument with the noalias attribute.
956
bool isNoAliasArgument(const Value *V);
957
958
/// Return true if this pointer refers to a distinct and identifiable object.
959
/// This returns true for:
960
///    Global Variables and Functions (but not Global Aliases)
961
///    Allocas
962
///    ByVal and NoAlias Arguments
963
///    NoAlias returns (e.g. calls to malloc)
964
///
965
bool isIdentifiedObject(const Value *V);
966
967
/// Return true if V is umabigously identified at the function-level.
968
/// Different IdentifiedFunctionLocals can't alias.
969
/// Further, an IdentifiedFunctionLocal can not alias with any function
970
/// arguments other than itself, which is not necessarily true for
971
/// IdentifiedObjects.
972
bool isIdentifiedFunctionLocal(const Value *V);
973
974
/// A manager for alias analyses.
975
///
976
/// This class can have analyses registered with it and when run, it will run
977
/// all of them and aggregate their results into single AA results interface
978
/// that dispatches across all of the alias analysis results available.
979
///
980
/// Note that the order in which analyses are registered is very significant.
981
/// That is the order in which the results will be aggregated and queried.
982
///
983
/// This manager effectively wraps the AnalysisManager for registering alias
984
/// analyses. When you register your alias analysis with this manager, it will
985
/// ensure the analysis itself is registered with its AnalysisManager.
986
class AAManager : public AnalysisInfoMixin<AAManager> {
987
public:
988
  using Result = AAResults;
989
990
  /// Register a specific AA result.
991
478
  template <typename AnalysisT> void registerFunctionAnalysis() {
992
478
    ResultGetters.push_back(&getFunctionAAResultImpl<AnalysisT>);
993
478
  }
void llvm::AAManager::registerFunctionAnalysis<llvm::BasicAA>()
Line
Count
Source
991
244
  template <typename AnalysisT> void registerFunctionAnalysis() {
992
244
    ResultGetters.push_back(&getFunctionAAResultImpl<AnalysisT>);
993
244
  }
void llvm::AAManager::registerFunctionAnalysis<llvm::ScopedNoAliasAA>()
Line
Count
Source
991
96
  template <typename AnalysisT> void registerFunctionAnalysis() {
992
96
    ResultGetters.push_back(&getFunctionAAResultImpl<AnalysisT>);
993
96
  }
void llvm::AAManager::registerFunctionAnalysis<llvm::TypeBasedAA>()
Line
Count
Source
991
101
  template <typename AnalysisT> void registerFunctionAnalysis() {
992
101
    ResultGetters.push_back(&getFunctionAAResultImpl<AnalysisT>);
993
101
  }
void llvm::AAManager::registerFunctionAnalysis<llvm::CFLAndersAA>()
Line
Count
Source
991
19
  template <typename AnalysisT> void registerFunctionAnalysis() {
992
19
    ResultGetters.push_back(&getFunctionAAResultImpl<AnalysisT>);
993
19
  }
void llvm::AAManager::registerFunctionAnalysis<llvm::CFLSteensAA>()
Line
Count
Source
991
17
  template <typename AnalysisT> void registerFunctionAnalysis() {
992
17
    ResultGetters.push_back(&getFunctionAAResultImpl<AnalysisT>);
993
17
  }
void llvm::AAManager::registerFunctionAnalysis<llvm::SCEVAA>()
Line
Count
Source
991
1
  template <typename AnalysisT> void registerFunctionAnalysis() {
992
1
    ResultGetters.push_back(&getFunctionAAResultImpl<AnalysisT>);
993
1
  }
994
995
  /// Register a specific AA result.
996
100
  template <typename AnalysisT> void registerModuleAnalysis() {
997
100
    ResultGetters.push_back(&getModuleAAResultImpl<AnalysisT>);
998
100
  }
999
1000
2.51k
  Result run(Function &F, FunctionAnalysisManager &AM) {
1001
2.51k
    Result R(AM.getResult<TargetLibraryAnalysis>(F));
1002
2.51k
    for (auto &Getter : ResultGetters)
1003
2.46k
      (*Getter)(F, AM, R);
1004
2.51k
    return R;
1005
2.51k
  }
1006
1007
private:
1008
  friend AnalysisInfoMixin<AAManager>;
1009
1010
  static AnalysisKey Key;
1011
1012
  SmallVector<void (*)(Function &F, FunctionAnalysisManager &AM,
1013
                       AAResults &AAResults),
1014
              4> ResultGetters;
1015
1016
  template <typename AnalysisT>
1017
  static void getFunctionAAResultImpl(Function &F,
1018
                                      FunctionAnalysisManager &AM,
1019
2.08k
                                      AAResults &AAResults) {
1020
2.08k
    AAResults.addAAResult(AM.template getResult<AnalysisT>(F));
1021
2.08k
    AAResults.addAADependencyID(AnalysisT::ID());
1022
2.08k
  }
void llvm::AAManager::getFunctionAAResultImpl<llvm::BasicAA>(llvm::Function&, llvm::AnalysisManager<llvm::Function>&, llvm::AAResults&)
Line
Count
Source
1019
1.22k
                                      AAResults &AAResults) {
1020
1.22k
    AAResults.addAAResult(AM.template getResult<AnalysisT>(F));
1021
1.22k
    AAResults.addAADependencyID(AnalysisT::ID());
1022
1.22k
  }
void llvm::AAManager::getFunctionAAResultImpl<llvm::ScopedNoAliasAA>(llvm::Function&, llvm::AnalysisManager<llvm::Function>&, llvm::AAResults&)
Line
Count
Source
1019
370
                                      AAResults &AAResults) {
1020
370
    AAResults.addAAResult(AM.template getResult<AnalysisT>(F));
1021
370
    AAResults.addAADependencyID(AnalysisT::ID());
1022
370
  }
void llvm::AAManager::getFunctionAAResultImpl<llvm::TypeBasedAA>(llvm::Function&, llvm::AnalysisManager<llvm::Function>&, llvm::AAResults&)
Line
Count
Source
1019
399
                                      AAResults &AAResults) {
1020
399
    AAResults.addAAResult(AM.template getResult<AnalysisT>(F));
1021
399
    AAResults.addAADependencyID(AnalysisT::ID());
1022
399
  }
void llvm::AAManager::getFunctionAAResultImpl<llvm::CFLAndersAA>(llvm::Function&, llvm::AnalysisManager<llvm::Function>&, llvm::AAResults&)
Line
Count
Source
1019
41
                                      AAResults &AAResults) {
1020
41
    AAResults.addAAResult(AM.template getResult<AnalysisT>(F));
1021
41
    AAResults.addAADependencyID(AnalysisT::ID());
1022
41
  }
void llvm::AAManager::getFunctionAAResultImpl<llvm::CFLSteensAA>(llvm::Function&, llvm::AnalysisManager<llvm::Function>&, llvm::AAResults&)
Line
Count
Source
1019
42
                                      AAResults &AAResults) {
1020
42
    AAResults.addAAResult(AM.template getResult<AnalysisT>(F));
1021
42
    AAResults.addAADependencyID(AnalysisT::ID());
1022
42
  }
void llvm::AAManager::getFunctionAAResultImpl<llvm::SCEVAA>(llvm::Function&, llvm::AnalysisManager<llvm::Function>&, llvm::AAResults&)
Line
Count
Source
1019
6
                                      AAResults &AAResults) {
1020
6
    AAResults.addAAResult(AM.template getResult<AnalysisT>(F));
1021
6
    AAResults.addAADependencyID(AnalysisT::ID());
1022
6
  }
1023
1024
  template <typename AnalysisT>
1025
  static void getModuleAAResultImpl(Function &F, FunctionAnalysisManager &AM,
1026
380
                                    AAResults &AAResults) {
1027
380
    auto &MAMProxy = AM.getResult<ModuleAnalysisManagerFunctionProxy>(F);
1028
380
    auto &MAM = MAMProxy.getManager();
1029
380
    if (auto *R = MAM.template getCachedResult<AnalysisT>(*F.getParent())) {
1030
257
      AAResults.addAAResult(*R);
1031
257
      MAMProxy
1032
257
          .template registerOuterAnalysisInvalidation<AnalysisT, AAManager>();
1033
257
    }
1034
380
  }
1035
};
1036
1037
/// A wrapper pass to provide the legacy pass manager access to a suitably
1038
/// prepared AAResults object.
1039
class AAResultsWrapperPass : public FunctionPass {
1040
  std::unique_ptr<AAResults> AAR;
1041
1042
public:
1043
  static char ID;
1044
1045
  AAResultsWrapperPass();
1046
1047
17.2M
  AAResults &getAAResults() { return *AAR; }
1048
0
  const AAResults &getAAResults() const { return *AAR; }
1049
1050
  bool runOnFunction(Function &F) override;
1051
1052
  void getAnalysisUsage(AnalysisUsage &AU) const override;
1053
};
1054
1055
/// A wrapper pass for external alias analyses. This just squirrels away the
1056
/// callback used to run any analyses and register their results.
1057
struct ExternalAAWrapperPass : ImmutablePass {
1058
  using CallbackT = std::function<void(Pass &, Function &, AAResults &)>;
1059
1060
  CallbackT CB;
1061
1062
  static char ID;
1063
1064
0
  ExternalAAWrapperPass() : ImmutablePass(ID) {
1065
0
    initializeExternalAAWrapperPassPass(*PassRegistry::getPassRegistry());
1066
0
  }
1067
1068
  explicit ExternalAAWrapperPass(CallbackT CB)
1069
2.52k
      : ImmutablePass(ID), CB(std::move(CB)) {
1070
2.52k
    initializeExternalAAWrapperPassPass(*PassRegistry::getPassRegistry());
1071
2.52k
  }
1072
1073
2.50k
  void getAnalysisUsage(AnalysisUsage &AU) const override {
1074
2.50k
    AU.setPreservesAll();
1075
2.50k
  }
1076
};
1077
1078
FunctionPass *createAAResultsWrapperPass();
1079
1080
/// A wrapper pass around a callback which can be used to populate the
1081
/// AAResults in the AAResultsWrapperPass from an external AA.
1082
///
1083
/// The callback provided here will be used each time we prepare an AAResults
1084
/// object, and will receive a reference to the function wrapper pass, the
1085
/// function, and the AAResults object to populate. This should be used when
1086
/// setting up a custom pass pipeline to inject a hook into the AA results.
1087
ImmutablePass *createExternalAAWrapperPass(
1088
    std::function<void(Pass &, Function &, AAResults &)> Callback);
1089
1090
/// A helper for the legacy pass manager to create a \c AAResults
1091
/// object populated to the best of our ability for a particular function when
1092
/// inside of a \c ModulePass or a \c CallGraphSCCPass.
1093
///
1094
/// If a \c ModulePass or a \c CallGraphSCCPass calls \p
1095
/// createLegacyPMAAResults, it also needs to call \p addUsedAAAnalyses in \p
1096
/// getAnalysisUsage.
1097
AAResults createLegacyPMAAResults(Pass &P, Function &F, BasicAAResult &BAR);
1098
1099
/// A helper for the legacy pass manager to populate \p AU to add uses to make
1100
/// sure the analyses required by \p createLegacyPMAAResults are available.
1101
void getAAResultsAnalysisUsage(AnalysisUsage &AU);
1102
1103
} // end namespace llvm
1104
1105
#endif // LLVM_ANALYSIS_ALIASANALYSIS_H