LLVM  16.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 
9 #include "ProvenanceAnalysis.h"
11 #include "llvm/ADT/SetVector.h"
13 #include "llvm/IR/Function.h"
14 #include "llvm/IR/InstIterator.h"
16 
17 using namespace llvm;
18 using namespace llvm::objcarc;
19 
20 static StringRef getName(Value *V) {
21  StringRef Name = V->getName();
22  if (Name.startswith("\1"))
23  return Name.substr(1);
24  return Name;
25 }
26 
27 static 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 
63  return PreservedAnalyses::all();
64 }
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:152
llvm::AAManager
A manager for alias analyses.
Definition: AliasAnalysis.h:876
getName
static StringRef getName(Value *V)
Definition: ProvenanceAnalysisEvaluator.cpp:20
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::AnalysisManager::getResult
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Definition: PassManager.h:774
InstIterator.h
llvm::Function
Definition: Function.h:60
llvm::Value::hasName
bool hasName() const
Definition: Value.h:261
llvm::PAEvalPass::run
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Definition: ProvenanceAnalysisEvaluator.cpp:33
llvm::errs
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
Definition: raw_ostream.cpp:891
llvm::objcarc::ProvenanceAnalysis
This is similar to BasicAliasAnalysis, and it uses many of the same techniques, except it uses specia...
Definition: ProvenanceAnalysis.h:51
F
#define F(x, y, z)
Definition: MD5.cpp:55
AliasAnalysis.h
Arg
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Definition: AMDGPULibCalls.cpp:187
llvm::Instruction
Definition: Instruction.h:42
llvm::objcarc::ProvenanceAnalysis::setAA
void setAA(AAResults *aa)
Definition: ProvenanceAnalysis.h:71
llvm::instructions
inst_range instructions(Function *F)
Definition: InstIterator.h:133
ProvenanceAnalysis.h
insertIfNamed
static void insertIfNamed(SetVector< Value * > &Values, Value *V)
Definition: ProvenanceAnalysisEvaluator.cpp:27
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::objcarc
Definition: ObjCARCAliasAnalysis.h:29
llvm::SetVector::insert
bool insert(const value_type &X)
Insert a new element into the SetVector.
Definition: SetVector.h:141
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
llvm::Value::getName
StringRef getName() const
Return a constant reference to the value's name.
Definition: Value.cpp:308
llvm::NVPTX::PTXLdStInstCode::V2
@ V2
Definition: NVPTX.h:123
llvm::AMDGPU::SendMsg::Op
Op
Definition: SIDefines.h:348
llvm::PreservedAnalyses::all
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: PassManager.h:158
Function.h
ObjCARC.h
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:42
raw_ostream.h
llvm::objcarc::ProvenanceAnalysis::related
bool related(const Value *A, const Value *B)
Definition: ProvenanceAnalysis.cpp:165
llvm::SetVector< Value * >
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
SetVector.h