diff --git a/llvm/include/llvm/IR/InstrTypes.h b/llvm/include/llvm/IR/InstrTypes.h --- a/llvm/include/llvm/IR/InstrTypes.h +++ b/llvm/include/llvm/IR/InstrTypes.h @@ -1401,6 +1401,13 @@ return nullptr; } + /// Returns the function called and removes the pointer casting around it + Function *getCalledFunctionRemovingPtrCasts() const { + if (auto *Operand = getCalledOperand()) + return dyn_cast_or_null(Operand->stripPointerCasts()); + return nullptr; + } + /// Return true if the callsite is an indirect call. bool isIndirectCall() const; diff --git a/llvm/lib/Target/NVPTX/NVVMReflect.cpp b/llvm/lib/Target/NVPTX/NVVMReflect.cpp --- a/llvm/lib/Target/NVPTX/NVVMReflect.cpp +++ b/llvm/lib/Target/NVPTX/NVVMReflect.cpp @@ -118,6 +118,8 @@ if (!Call) continue; Function *Callee = Call->getCalledFunction(); + if (!Callee) + Callee = Call->getCalledFunctionRemovingPtrCasts(); if (!Callee || (Callee->getName() != NVVM_REFLECT_FUNCTION && Callee->getIntrinsicID() != Intrinsic::nvvm_reflect)) continue;