[llvm-dev] Need help in understanding CallSite

Mircea Trofin via llvm-dev llvm-dev at lists.llvm.org
Sun Feb 21 08:40:16 PST 2021


CallSite and CallSiteBase were removed in fdbf493a705c
<https://github.com/llvm/llvm-project/commit/fdbf493a705c>. I'm assuming
you're working on a branch before that. To future-proof the code, it'd be
probably best to not use CallSite, and instead use CallBase (an
Instruction, base class to CallInst, CallBrInst or InvokeInst) and get the
information from it, e.g. getCalledOperand.

For your case, could it be that the use of the function is not a call, but,
for example, an expression taking the address of the function? When
debugging, I find it useful to call dump() on the various objects of
interest, it very quickly reveals what's happening.

On Sun, Feb 21, 2021 at 3:07 AM Nagaraju Mekala via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> Hi All,
>
> I have a custom Pass which will identify a few functions in the .cpp
> code and process them.
> It was working fine for almost all the functions except for a function
> which has class objects as its arguments.
>
> Details:
> For a particular function the  CallSite CS(*iUse); CS is zero. When I
> debugged the code the CallSite was expecting the *iUse to be InstTy
> but this particular function is having the type UnaryConstantExpr. Due
> to this the CS is zero.
>
> I want to understand why this specific function has the UnaryConstantExpr
> type?
> Any reference to documents or links will be a great help.
>
> CallSite.h:
> static CallSiteBase get(ValTy *V) {
>     if (InstrTy *II = dyn_cast<InstrTy>(V)) {
>
> CustomPass:
> //aFuncs has the custom functions list from .cpp
> for(AFuncList::iterator iFunc=aFuncs.begin(); iFunc!=aFuncs.end();
> iFunc++){
>       Function *f = *iFunc;
>       for(Value::user_iterator iUse = f->user_begin(); iUse !=
> f->user_end(); iUse++){
>         CallSite CS(*iUse);
>         if ( CS ){
>           BasicBlock *bb = CS.getInstruction()->getParent();
>            -----
>            ---
>
> Please let me know if more details are needed.
>
> Thanks in Advance,
> Nagaraju
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210221/f3fee707/attachment.html>


More information about the llvm-dev mailing list