24 #define DEBUG_TYPE "abstract-call-sites" 26 STATISTIC(NumCallbackCallSites,
"Number of callback call sites created");
28 "Number of direct abstract call sites created");
29 STATISTIC(NumInvalidAbstractCallSitesUnknownUse,
30 "Number of invalid abstract call sites created (unknown use)");
31 STATISTIC(NumInvalidAbstractCallSitesUnknownCallee,
32 "Number of invalid abstract call sites created (unknown callee)");
33 STATISTIC(NumInvalidAbstractCallSitesNoCallback,
34 "Number of invalid abstract call sites created (no callback)");
47 MDNode *OpMD = cast<MDNode>(
Op.get());
48 auto *CBCalleeIdxAsCM = cast<ConstantAsMetadata>(OpMD->
getOperand(0));
49 uint64_t CBCalleeIdx =
50 cast<ConstantInt>(CBCalleeIdxAsCM->getValue())->getZExtValue();
65 if (
ConstantExpr *CE = dyn_cast<ConstantExpr>(U->getUser()))
66 if (CE->getNumUses() == 1 && CE->isCast()) {
67 U = &*CE->use_begin();
72 NumInvalidAbstractCallSitesUnknownUse++;
80 NumDirectAbstractCallSites++;
88 NumInvalidAbstractCallSitesUnknownCallee++;
95 NumInvalidAbstractCallSitesNoCallback++;
101 MDNode *CallbackEncMD =
nullptr;
103 MDNode *OpMD = cast<MDNode>(
Op.get());
104 auto *CBCalleeIdxAsCM = cast<ConstantAsMetadata>(OpMD->
getOperand(0));
105 uint64_t CBCalleeIdx =
106 cast<ConstantInt>(CBCalleeIdxAsCM->getValue())->getZExtValue();
107 if (CBCalleeIdx != UseIdx)
109 CallbackEncMD = OpMD;
113 if (!CallbackEncMD) {
114 NumInvalidAbstractCallSitesNoCallback++;
119 NumCallbackCallSites++;
127 auto *OpAsCM = cast<ConstantAsMetadata>(OpAsM);
128 assert(OpAsCM->getType()->isIntegerTy(64) &&
129 "Malformed !callback metadata");
131 int64_t Idx = cast<ConstantInt>(OpAsCM->getValue())->getSExtValue();
132 assert(-1 <= Idx && Idx <= NumCallOperands &&
133 "Out-of-bounds !callback metadata index");
143 auto *VarArgFlagAsCM = cast<ConstantAsMetadata>(VarArgFlagAsM);
144 assert(VarArgFlagAsCM->getType()->isIntegerTy(1) &&
145 "Malformed !callback metadata var-arg flag");
147 if (VarArgFlagAsCM->getValue()->isNullValue())
151 for (
unsigned u = Callee->
arg_size(); u < NumCallOperands; u++)
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
Tracking metadata reference owned by Metadata.
This class represents lattice values for constants.
void push_back(const T &Elt)
STATISTIC(NumFunctions, "Total number of functions")
const MDOperand & getOperand(unsigned I) const
FunTy * getCalledFunction() const
Return the function being called if this is a direct call, otherwise return null (if it's an indirect...
A Use represents the edge between a Value definition and its users.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
unsigned getArgumentNo(Value::const_user_iterator I) const
Given a value use iterator, returns the argument that corresponds to it.
A constant value that is initialized with an expression using other constant values.
op_range operands() const
ParameterEncodingTy ParameterEncoding
static void getCallbackUses(ImmutableCallSite ICS, SmallVectorImpl< const Use *> &CBUses)
Add operand uses of ICS that represent callback uses into CBUses.
unsigned getNumArgOperands() const
amdgpu Simplify well known AMD library false FunctionCallee Callee
Establish a view to a call site for examination.
AbstractCallSite(const Use *U)
Sole constructor for abstract call sites (ACS).
bool isCallee(Value::const_user_iterator UI) const
Determine whether the passed iterator points to the callee operand's Use.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned getNumOperands() const
Return number of MDNode operands.