[llvm-dev] Need help in understanding CallSite

Nagaraju Mekala via llvm-dev llvm-dev at lists.llvm.org
Sun Feb 21 03:07:19 PST 2021


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


More information about the llvm-dev mailing list