LLVM 19.0.0git
ProvenanceAnalysisEvaluator.cpp
Go to the documentation of this file.
1//===- ProvenanceAnalysisEvaluator.cpp - ObjC ARC Optimization ------------===//
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
11#include "llvm/ADT/SetVector.h"
13#include "llvm/IR/Function.h"
16
17using namespace llvm;
18using namespace llvm::objcarc;
19
21 StringRef Name = V->getName();
22 if (Name.starts_with("\1"))
23 return Name.substr(1);
24 return Name;
25}
26
27static void insertIfNamed(SetVector<Value *> &Values, Value *V) {
28 if (!V->hasName())
29 return;
30 Values.insert(V);
31}
32
34 SetVector<Value *> Values;
35
36 for (auto &Arg : F.args())
37 insertIfNamed(Values, &Arg);
38
39 for (Instruction &I : instructions(F)) {
40 insertIfNamed(Values, &I);
41
42 for (auto &Op : I.operands())
43 insertIfNamed(Values, Op);
44 }
45
47 PA.setAA(&AM.getResult<AAManager>(F));
48
49 for (Value *V1 : Values) {
50 StringRef NameV1 = getName(V1);
51 for (Value *V2 : Values) {
52 StringRef NameV2 = getName(V2);
53 if (NameV1 >= NameV2)
54 continue;
55 errs() << NameV1 << " and " << NameV2;
56 if (PA.related(V1, V2))
57 errs() << " are related.\n";
58 else
59 errs() << " are not related.\n";
60 }
61 }
62
64}
Expand Atomic instructions
std::string Name
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
static void insertIfNamed(SetVector< Value * > &Values, Value *V)
static StringRef getName(Value *V)
This file declares a special form of Alias Analysis called Provenance Analysis''.
This file implements a set that has insertion order iteration characteristics.
A manager for alias analyses.
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:348
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Definition: PassManager.h:500
This class represents an Operation in the Expression.
A set of analyses that are preserved following a run of a transformation pass.
Definition: Analysis.h:109
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: Analysis.h:115
A vector that has set insertion semantics.
Definition: SetVector.h:57
bool insert(const value_type &X)
Insert a new element into the SetVector.
Definition: SetVector.h:162
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
LLVM Value Representation.
Definition: Value.h:74
This is similar to BasicAliasAnalysis, and it uses many of the same techniques, except it uses specia...
bool related(const Value *A, const Value *B)
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)