comparison docs/AliasAnalysis.rst @ 77:54457678186b LLVM3.6

LLVM 3.6
author Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
date Mon, 08 Sep 2014 22:06:00 +0900
parents 95c75e76d11b
children afa8332a0e37
comparison
equal deleted inserted replaced
34:e874dbf0ad9d 77:54457678186b
49 ``call`` or ``invoke`` instructions that performs the call. The 49 ``call`` or ``invoke`` instructions that performs the call. The
50 ``AliasAnalysis`` interface also exposes some helper methods which allow you to 50 ``AliasAnalysis`` interface also exposes some helper methods which allow you to
51 get mod/ref information for arbitrary instructions. 51 get mod/ref information for arbitrary instructions.
52 52
53 All ``AliasAnalysis`` interfaces require that in queries involving multiple 53 All ``AliasAnalysis`` interfaces require that in queries involving multiple
54 values, values which are not `constants <LangRef.html#constants>`_ are all 54 values, values which are not :ref:`constants <constants>` are all
55 defined within the same function. 55 defined within the same function.
56 56
57 Representation of Pointers 57 Representation of Pointers
58 -------------------------- 58 --------------------------
59 59
109 two memory objects alias each other. It takes two memory objects as input and 109 two memory objects alias each other. It takes two memory objects as input and
110 returns MustAlias, PartialAlias, MayAlias, or NoAlias as appropriate. 110 returns MustAlias, PartialAlias, MayAlias, or NoAlias as appropriate.
111 111
112 Like all ``AliasAnalysis`` interfaces, the ``alias`` method requires that either 112 Like all ``AliasAnalysis`` interfaces, the ``alias`` method requires that either
113 the two pointer values be defined within the same function, or at least one of 113 the two pointer values be defined within the same function, or at least one of
114 the values is a `constant <LangRef.html#constants>`_. 114 the values is a :ref:`constant <constants>`.
115 115
116 .. _Must, May, or No: 116 .. _Must, May, or No:
117 117
118 Must, May, and No Alias Responses 118 Must, May, and No Alias Responses
119 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 119 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
124 non-overlapping memory ranges. Another is when the two pointers are only ever 124 non-overlapping memory ranges. Another is when the two pointers are only ever
125 used for reading memory. Another is when the memory is freed and reallocated 125 used for reading memory. Another is when the memory is freed and reallocated
126 between accesses through one pointer and accesses through the other --- in this 126 between accesses through one pointer and accesses through the other --- in this
127 case, there is a dependence, but it's mediated by the free and reallocation. 127 case, there is a dependence, but it's mediated by the free and reallocation.
128 128
129 As an exception to this is with the `noalias <LangRef.html#noalias>`_ keyword; 129 As an exception to this is with the :ref:`noalias <noalias>` keyword;
130 the "irrelevant" dependencies are ignored. 130 the "irrelevant" dependencies are ignored.
131 131
132 The ``MayAlias`` response is used whenever the two pointers might refer to the 132 The ``MayAlias`` response is used whenever the two pointers might refer to the
133 same object. 133 same object.
134 134
242 242
243 bool run(Module &M) { 243 bool run(Module &M) {
244 InitializeAliasAnalysis(this); 244 InitializeAliasAnalysis(this);
245 // Perform analysis here... 245 // Perform analysis here...
246 return false; 246 return false;
247 }
248
249 Required methods to override
250 ----------------------------
251
252 You must override the ``getAdjustedAnalysisPointer`` method on all subclasses
253 of ``AliasAnalysis``. An example implementation of this method would look like:
254
255 .. code-block:: c++
256
257 void *getAdjustedAnalysisPointer(const void* ID) override {
258 if (ID == &AliasAnalysis::ID)
259 return (AliasAnalysis*)this;
260 return this;
247 } 261 }
248 262
249 Interfaces which may be specified 263 Interfaces which may be specified
250 --------------------------------- 264 ---------------------------------
251 265