LLVM: lib/Analysis/ScalarEvolutionAliasAnalysis.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

25using namespace llvm;

26

35

39

40

41

44

45

46 const SCEV *AS = SE.getSCEV(const_cast<Value *>(LocA.Ptr));

47 const SCEV *BS = SE.getSCEV(const_cast<Value *>(LocB.Ptr));

48

49

50 if (AS == BS)

52

53

54

63

64

65

66

67

68 const SCEV *AInt =

69 SE.getPtrToIntExpr(AS, SE.getEffectiveSCEVType(AS->getType()));

70 const SCEV *BInt =

71 SE.getPtrToIntExpr(BS, SE.getEffectiveSCEVType(BS->getType()));

73 AS = AInt;

74 BS = BInt;

75 }

76

77

78 const SCEV *BA = SE.getMinusSCEV(BS, AS);

79

80

81

82

84 ASizeInt.ule(SE.getUnsignedRange(BA).getUnsignedMin()) &&

85 (-BSizeInt).uge(SE.getUnsignedRange(BA).getUnsignedMax()))

87

88

89

90

91

92

93 const SCEV *AB = SE.getMinusSCEV(AS, BS);

94

95

96

97

99 BSizeInt.ule(SE.getUnsignedRange(AB).getUnsignedMin()) &&

100 (-ASizeInt).uge(SE.getUnsignedRange(AB).getUnsignedMax()))

102 }

103

104

105

106

107 Value *AO = GetBaseValue(AS);

108 Value *BO = GetBaseValue(BS);

109 if ((AO && AO != LocA.Ptr) || (BO && BO != LocB.Ptr))

120

122}

123

124

125

126

127Value *SCEVAAResult::GetBaseValue(const SCEV *S) {

129

130

131 return GetBaseValue(AR->getStart());

133

134 const SCEV *Last = A->getOperand(A->getNumOperands() - 1);

135 if (Last->getType()->isPointerTy())

136 return GetBaseValue(Last);

138

139 return U->getValue();

140 }

141

142 return nullptr;

143}

144

146 FunctionAnalysisManager::Invalidator &Inv) {

147

148

150}

151

153

157

160 "ScalarEvolution-based Alias Analysis", false, true)

163 "ScalarEvolution-based Alias Analysis", false, true)

164

168

170

172 Result.reset(

174 return false;

175}

176

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

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

#define INITIALIZE_PASS_DEPENDENCY(depName)

#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)

#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)

static bool canComputePointerDiff(ScalarEvolution &SE, const SCEV *A, const SCEV *B)

Definition ScalarEvolutionAliasAnalysis.cpp:27

This is the interface for a SCEV-based alias analysis.

This class stores info we want to provide to or retain within an alias query.

Class for arbitrary precision integers.

bool ule(const APInt &RHS) const

Unsigned less or equal comparison.

The possible results of an alias query.

@ MayAlias

The two locations may or may not alias.

@ NoAlias

The two locations do not alias at all.

@ MustAlias

The two locations precisely alias each other.

PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)

Get the result of an analysis pass for a given IR unit.

Represent the analysis usage information of a pass.

AnalysisUsage & addRequired()

void setPreservesAll()

Set by analyses that do not transform their input at all.

FunctionPass class - This class is used to implement most global optimizations.

static constexpr LocationSize beforeOrAfterPointer()

Any location before or after the base pointer (but still within the underlying object).

TypeSize getValue() const

Representation for a specific memory location.

LocationSize Size

The maximum size of the location, in address-units, or UnknownSize if the size is not known.

AAMDNodes AATags

The metadata nodes which describes the aliasing of the location (each member is null if that kind of ...

const Value * Ptr

The address of the start of the location.

AnalysisType & getAnalysis() const

getAnalysis() - This function is used by subclasses to get to the analysis information ...

A set of analyses that are preserved following a run of a transformation pass.

A simple alias analysis implementation that uses ScalarEvolution to answer queries.

LLVM_ABI bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &Inv)

Definition ScalarEvolutionAliasAnalysis.cpp:145

LLVM_ABI AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB, AAQueryInfo &AAQI, const Instruction *CtxI)

Definition ScalarEvolutionAliasAnalysis.cpp:36

Legacy wrapper pass to provide the SCEVAAResult object.

void getAnalysisUsage(AnalysisUsage &AU) const override

getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...

Definition ScalarEvolutionAliasAnalysis.cpp:177

bool runOnFunction(Function &F) override

runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.

Definition ScalarEvolutionAliasAnalysis.cpp:171

SCEVAAWrapperPass()

Definition ScalarEvolutionAliasAnalysis.cpp:169

LLVM_ABI SCEVAAResult run(Function &F, FunctionAnalysisManager &AM)

Definition ScalarEvolutionAliasAnalysis.cpp:154

This node represents an addition of some number of SCEVs.

This node represents a polynomial recurrence on the trip count of the specified loop.

This class represents an analyzed expression in the program.

LLVM_ABI Type * getType() const

Return the LLVM type of this SCEV expression.

Analysis pass that exposes the ScalarEvolution for a function.

The main scalar evolution driver.

LLVM_ABI Type * getEffectiveSCEVType(Type *Ty) const

Return a type with the same bitwidth as the given type and which represents how SCEV will treat the g...

LLVM_ABI bool instructionCouldExistWithOperands(const SCEV *A, const SCEV *B)

Return true if there exists a point in the program at which both A and B could be operands to the sam...

LLVM Value Representation.

This is an optimization pass for GlobalISel generic memory operations.

decltype(auto) dyn_cast(const From &Val)

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

LLVM_ABI FunctionPass * createSCEVAAWrapperPass()

Creates an instance of SCEVAAWrapperPass.

Definition ScalarEvolutionAliasAnalysis.cpp:165

bool isa(const From &Val)

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

constexpr unsigned BitWidth

AnalysisManager< Function > FunctionAnalysisManager

Convenience typedef for the Function analysis manager.

A collection of metadata nodes that might be associated with a memory access used by the alias-analys...

A special type used by analysis passes to provide an address that identifies that particular analysis...