LLVM 22.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 if (!V->getType()->isPointerTy())
31 return;
32 Values.insert(V);
33}
34
36 SetVector<Value *> Values;
37
38 for (auto &Arg : F.args())
39 insertIfNamed(Values, &Arg);
40
41 for (Instruction &I : instructions(F)) {
42 insertIfNamed(Values, &I);
43
44 for (auto &Op : I.operands())
45 insertIfNamed(Values, Op);
46 }
47
49 PA.setAA(&AM.getResult<AAManager>(F));
50
51 for (Value *V1 : Values) {
52 StringRef NameV1 = getName(V1);
53 for (Value *V2 : Values) {
54 StringRef NameV2 = getName(V2);
55 if (NameV1 >= NameV2)
56 continue;
57 errs() << NameV1 << " and " << NameV2;
58 if (PA.related(V1, V2))
59 errs() << " are related.\n";
60 else
61 errs() << " are not related.\n";
62 }
63 }
64
66}
Expand Atomic instructions
#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.
bool related(const Value *A, const Value *B)
void setAA(AAResults *aa)
A manager for alias analyses.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition Analysis.h:118
A vector that has set insertion semantics.
Definition SetVector.h:59
bool insert(const value_type &X)
Insert a new element into the SetVector.
Definition SetVector.h:168
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
LLVM Value Representation.
Definition Value.h:75
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
DWARFExpression::Operation Op
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)