<dt><tt>cast<></tt>: </dt>
<dd><p>The <tt>cast<></tt> operator is a "checked cast" operation. It
- converts a pointer or reference from a base class to a derived cast, causing
+ converts a pointer or reference from a base class to a derived class, causing
an assertion failure if it is not really an instance of the right type. This
should be used in cases where you have some information that makes you believe
that something is of the right type. An example of the <tt>isa<></tt>
virtual runOnFunction(Function& F) {
for (Function::iterator b = F.begin(), be = F.end(); b != be; ++b) {
- for (BasicBlock::iterator i = b->begin(); ie = b->end(); i != ie; ++i) {
+ for (BasicBlock::iterator i = b->begin(), ie = b->end(); i != ie; ++i) {
if (<a href="#CallInst">CallInst</a>* callInst = <a href="#isa">dyn_cast</a><<a
href="#CallInst">CallInst</a>>(&*i)) {
// <i>We know we've encountered a call instruction, so we</i>
<ul>
<li><tt>ReplaceInstWithValue</tt>
- <p>This function replaces all uses (within a basic block) of a given
- instruction with a value, and then removes the original instruction. The
- following example illustrates the replacement of the result of a particular
+ <p>This function replaces all uses of a given instruction with a value,
+ and then removes the original instruction. The following example
+ illustrates the replacement of the result of a particular
<tt>AllocaInst</tt> that allocates memory for a single integer with a null
pointer to an integer.</p>
BasicBlock::iterator ii(instToReplace);
ReplaceInstWithValue(instToReplace->getParent()->getInstList(), ii,
- Constant::getNullValue(PointerType::get(Type::Int32Ty)));
+ Constant::getNullValue(PointerType::getUnqual(Type::Int32Ty)));
</pre></div></li>
<li><tt>ReplaceInstWithInst</tt>
<p>This function replaces a particular instruction with another
- instruction. The following example illustrates the replacement of one
- <tt>AllocaInst</tt> with another.</p>
+ instruction, inserting the new instruction into the basic block at the
+ location where the old instruction was, and replacing any uses of the old
+ instruction with the new instruction. The following example illustrates
+ the replacement of one <tt>AllocaInst</tt> with another.</p>
<div class="doc_code">
<pre>
// <i>Create the initial outer struct</i>
<a href="#PATypeHolder">PATypeHolder</a> StructTy = OpaqueType::get();
std::vector<const Type*> Elts;
-Elts.push_back(PointerType::get(StructTy));
+Elts.push_back(PointerType::getUnqual(StructTy));
Elts.push_back(Type::Int32Ty);
StructType *NewSTy = StructType::get(Elts);
<div class="doc_text">
<p>The <tt><a href="http://llvm.org/doxygen/classllvm_1_1User.html">
-User</a></tt> class provides a base for expressing the ownership of <tt>User</tt>
+User</a></tt> class provides a basis for expressing the ownership of <tt>User</tt>
towards other <tt><a href="http://llvm.org/doxygen/classllvm_1_1Value.html">
Value</a></tt>s. The <tt><a href="http://llvm.org/doxygen/classllvm_1_1Use.html">
Use</a></tt> helper class is employed to do the bookkeeping and to facilitate <i>O(1)</i>
<!-- ______________________________________________________________________ -->
<div class="doc_subsubsection">
- <a name="PATypeHolder">Interaction and relationship between <tt>User</tt> and <tt>Use</tt> objects</a>
+ <a name="Use2User">Interaction and relationship between <tt>User</tt> and <tt>Use</tt> objects</a>
</div>
<div class="doc_text">
number of them.</p>
</ul>
<p>
-Initially each layout will possess a direct pointer to the
+As of v2.4 each layout still possesses a direct pointer to the
start of the array of <tt>Use</tt>s. Though not mandatory for layout a),
we stick to this redundancy for the sake of simplicity.
-The <tt>User</tt> object will also store the number of <tt>Use</tt> objects it
+The <tt>User</tt> object also stores the number of <tt>Use</tt> objects it
has. (Theoretically this information can also be calculated
given the scheme presented below.)</p>
<p>
Special forms of allocation operators (<tt>operator new</tt>)
-will enforce the following memory layouts:</p>
+enforce the following memory layouts:</p>
<ul>
-<li><p>Layout a) will be modelled by prepending the <tt>User</tt> object by the <tt>Use[]</tt> array.</p>
+<li><p>Layout a) is modelled by prepending the <tt>User</tt> object by the <tt>Use[]</tt> array.</p>
<pre>
...---.---.---.---.-------...
'''---'---'---'---'-------'''
</pre>
-<li><p>Layout b) will be modelled by pointing at the Use[] array.</p>
+<li><p>Layout b) is modelled by pointing at the <tt>Use[]</tt> array.</p>
<pre>
.-------...
| User
<!-- ______________________________________________________________________ -->
<div class="doc_subsubsection">
- <a name="PATypeHolder">The waymarking algorithm</a>
+ <a name="Waymarking">The waymarking algorithm</a>
</div>
<div class="doc_text">
<p>
-Since the <tt>Use</tt> objects will be deprived of the direct pointer to
+Since the <tt>Use</tt> objects are deprived of the direct (back)pointer to
their <tt>User</tt> objects, there must be a fast and exact method to
recover it. This is accomplished by the following scheme:</p>
</div>
-A bit-encoding in the 2 LSBits (least significant bits) of the <tt>Use::Prev</tt> will allow to find the
+A bit-encoding in the 2 LSBits (least significant bits) of the <tt>Use::Prev</tt> allows to find the
start of the <tt>User</tt> object:
<ul>
<li><tt>00</tt> —> binary digit 0</li>
<!-- ______________________________________________________________________ -->
<div class="doc_subsubsection">
- <a name="PATypeHolder">Reference implementation</a>
+ <a name="ReferenceImpl">Reference implementation</a>
</div>
<div class="doc_text">
<!-- ______________________________________________________________________ -->
<div class="doc_subsubsection">
- <a name="PATypeHolder">Tagging considerations</a>
+ <a name="Tagging">Tagging considerations</a>
</div>
<p>
new <tt>Use**</tt> on every modification. Accordingly getters must strip the
tag bits.</p>
<p>
-For layout b) instead of the <tt>User</tt> we will find a pointer (<tt>User*</tt> with LSBit set).
-Following this pointer brings us to the <tt>User</tt>. A portable trick will ensure
-that the first bytes of <tt>User</tt> (if interpreted as a pointer) will never have
-the LSBit set.</p>
+For layout b) instead of the <tt>User</tt> we find a pointer (<tt>User*</tt> with LSBit set).
+Following this pointer brings us to the <tt>User</tt>. A portable trick ensures
+that the first bytes of <tt>User</tt> (if interpreted as a pointer) never has
+the LSBit set. (Portability is relying on the fact that all known compilers place the
+<tt>vptr</tt> in the first word of the instances.)</p>
</div>
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
- <a name="m_Value">Important Public Methods</a>
+ <a name="m_Type">Important Public Methods</a>
</div>
<div class="doc_text">
<!-- _______________________________________________________________________ -->
<div class="doc_subsubsection">
- <a name="m_Value">Important Derived Types</a>
+ <a name="derivedtypes">Important Derived Types</a>
</div>
<div class="doc_text">
<dl>
will automatically be inserted into that module's list of
functions.</p></li>
- <li><tt>bool isExternal()</tt>
+ <li><tt>bool isDeclaration()</tt>
<p>Return whether or not the <tt>Function</tt> has a body defined. If the
function is "external", it does not have a body, and thus must be resolved
<hr>
<address>
<a href="http://jigsaw.w3.org/css-validator/check/referer"><img
- src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
+ src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS"></a>
<a href="http://validator.w3.org/check/referer"><img
- src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /></a>
+ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Strict"></a>
<a href="mailto:dhurjati@cs.uiuc.edu">Dinakar Dhurjati</a> and
<a href="mailto:sabre@nondot.org">Chris Lattner</a><br>