Skip to content

Commit

Permalink
[CallSite removal] Remove the text describing CallSite from the manual.
Browse files Browse the repository at this point in the history
  • Loading branch information
jyknight committed Apr 24, 2020
1 parent 5b89c1d commit fb8152d
Showing 1 changed file with 6 additions and 27 deletions.
33 changes: 6 additions & 27 deletions llvm/docs/ProgrammersManual.rst
Expand Up @@ -2620,7 +2620,7 @@ want to do:
for each Function f in the Module
for each BasicBlock b in f
for each Instruction i in b
if (i is a CallInst and calls the given function)
if (i a Call and calls the given function)
increment callCounter
And the actual code is (remember, because we're writing a ``FunctionPass``, our
Expand All @@ -2638,11 +2638,11 @@ method):
virtual runOnFunction(Function& F) {
for (BasicBlock &B : F) {
for (Instruction &I: B) {
if (auto *CallInst = dyn_cast<CallInst>(&I)) {
// We know we've encountered a call instruction, so we
// need to determine if it's a call to the
// function pointed to by m_func or not.
if (CallInst->getCalledFunction() == targetFunc)
if (auto *CB = dyn_cast<CallBase>(&I)) {
// We know we've encountered some kind of call instruction (call,
// invoke, or callbr), so we need to determine if it's a call to
// the function pointed to by m_func or not.
if (CB->getCalledFunction() == targetFunc)
++callCounter;
}
}
Expand All @@ -2653,27 +2653,6 @@ method):
unsigned callCounter;
};

.. _calls_and_invokes:

Treating calls and invokes the same way
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

You may have noticed that the previous example was a bit oversimplified in that
it did not deal with call sites generated by 'invoke' instructions. In this,
and in other situations, you may find that you want to treat ``CallInst``\ s and
``InvokeInst``\ s the same way, even though their most-specific common base
class is ``Instruction``, which includes lots of less closely-related things.
For these cases, LLVM provides a handy wrapper class called ``CallSite``
(`doxygen <https://llvm.org/doxygen/classllvm_1_1CallSite.html>`__) It is
essentially a wrapper around an ``Instruction`` pointer, with some methods that
provide functionality common to ``CallInst``\ s and ``InvokeInst``\ s.

This class has "value semantics": it should be passed by value, not by reference
and it should not be dynamically allocated or deallocated using ``operator new``
or ``operator delete``. It is efficiently copyable, assignable and
constructable, with costs equivalents to that of a bare pointer. If you look at
its definition, it has only a single pointer member.

.. _iterate_chains:

Iterating over def-use & use-def chains
Expand Down

0 comments on commit fb8152d

Please sign in to comment.