LLVM: lib/Transforms/ObjCARC/ProvenanceAnalysis.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

35#include

36

37using namespace llvm;

39

40bool ProvenanceAnalysis::relatedSelect(const SelectInst *A,

42

43

45 if (A->getCondition() == SB->getCondition())

46 return related(A->getTrueValue(), SB->getTrueValue()) ||

47 related(A->getFalseValue(), SB->getFalseValue());

48

49

50 return related(A->getTrueValue(), B) || related(A->getFalseValue(), B);

51}

52

53bool ProvenanceAnalysis::relatedPHI(const PHINode *A,

55

56

57

59 if (PNB->getParent() == A->getParent()) {

60 for (unsigned i = 0, e = A->getNumIncomingValues(); i != e; ++i)

61 if (related(A->getIncomingValue(i),

62 PNB->getIncomingValueForBlock(A->getIncomingBlock(i))))

63 return true;

64 return false;

65 }

66

67

68 SmallPtrSet<const Value *, 4> UniqueSrc;

69 for (Value *PV1 : A->incoming_values()) {

71 return true;

72 }

73

74

75 return false;

76}

77

78

79

81 if (P->hasUseList())

82 return true;

83

88 do {

90 for (const Use &U : P->uses()) {

91 const User *Ur = U.getUser();

93 if (U.getOperandNo() == 0)

94

95 return true;

96

97 continue;

98 }

100

101 continue;

103

104 return true;

105 if (Visited.insert(Ur).second)

107 }

108 } while (!Worklist.empty());

109

110

111 return false;

112}

113

114bool ProvenanceAnalysis::relatedCheck(const Value *A, const Value *B) {

115

116 switch (AA->alias(A, B)) {

118 return false;

121 return true;

123 break;

124 }

125

128

129

130 if (AIsIdentified) {

131

134 if (BIsIdentified) {

135

138

139 return false;

140 }

141 } else if (BIsIdentified) {

142

145 }

146

147

149 return relatedPHI(PN, B);

151 return relatedPHI(PN, A);

153 return relatedSelect(S, B);

155 return relatedSelect(S, A);

156

157

158 return true;

159}

160

164

165

166 if (A == B)

167 return true;

168

169

170

171

172 std::pair<CachedResultsTy::iterator, bool> Pair =

173 CachedResults.insert(std::make_pair(ValuePairTy(A, B), true));

174 if (!Pair.second)

175 return Pair.first->second;

176

177 bool Result = relatedCheck(A, B);

178 CachedResults[ValuePairTy(A, B)] = Result;

179 return Result;

180}

static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")

static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")

This defines the Use class.

This file defines common analysis utilities used by the ObjC ARC Optimizer.

static bool IsStoredObjCPointer(const Value *P)

Test if the value of P, or any value covered by its provenance, is ever stored within the function (n...

Definition ProvenanceAnalysis.cpp:80

This file declares a special form of Alias Analysis called Provenance / Analysis''.

This file defines the SmallPtrSet class.

This file defines the SmallVector class.

bool related(const Value *A, const Value *B)

Definition ProvenanceAnalysis.cpp:161

@ MayAlias

The two locations may or may not alias.

@ NoAlias

The two locations do not alias at all.

@ PartialAlias

The two locations alias, but only due to a partial overlap.

@ MustAlias

The two locations precisely alias each other.

This class represents the LLVM 'select' instruction.

std::pair< iterator, bool > insert(PtrType Ptr)

Inserts Ptr if and only if there is no element in the container equal to Ptr.

SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.

void push_back(const T &Elt)

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

A Use represents the edge between a Value definition and its users.

LLVM Value Representation.

bool IsObjCIdentifiedObject(const Value *V)

Return true if this value refers to a distinct and identifiable object.

const Value * GetUnderlyingObjCPtrCached(const Value *V, DenseMap< const Value *, std::pair< WeakVH, WeakTrackingVH > > &Cache)

A wrapper for GetUnderlyingObjCPtr used for results memoization.

This is an optimization pass for GlobalISel generic memory operations.

FunctionAddr VTableAddr Value

decltype(auto) dyn_cast(const From &Val)

dyn_cast - Return the argument parameter cast to the specified type.

bool isa(const From &Val)

isa - Return true if the parameter to the template is an instance of one of the template type argu...