[CallSite removal] Remove the text describing CallSite from the manual.

This commit is contained in:
James Y Knight 2020-04-23 22:01:09 -04:00
parent 5b89c1dd68
commit fb8152dcfe
1 changed files with 6 additions and 27 deletions

View File

@ -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
@ -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;
}
}
@ -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