MCPcopy Create free account
hub / github.com/Samsung/UTopia / handleUser

Method handleUser

lib/propanalysis/AllocSizeAnalyzer.cpp:92–254  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90}
91
92void AllocSizeAnalyzer::handleUser(StackFrame &Frame, llvm::Value &User,
93 std::stack<StackFrame> &DefUseChains,
94 std::set<llvm::Value *> &VisitedNodes) {
95 Value *Def = Frame.Value;
96 ArgFlow &DefFlow = Frame.AnalysisResult;
97 auto &A = DefFlow.getLLVMArg();
98
99 if (auto *CB = dyn_cast<CallBase>(&User)) {
100 if (auto *II = dyn_cast<IntrinsicInst>(CB)) {
101 if (II->getIntrinsicID() != llvm::Intrinsic::umul_with_overflow)
102 return;
103 assert((II->getNumOperands() >= 2) && "Unexpected Program State");
104
105 auto *Op0 = II->getOperand(0);
106 auto *Op1 = II->getOperand(1);
107 if ((VisitedNodes.find(Op0) == VisitedNodes.end()) &&
108 (VisitedNodes.find(Op1) == VisitedNodes.end()))
109 return;
110
111 DefUseChains.emplace(&User, DefFlow);
112 return;
113 }
114
115 if (auto *CF = util::getCalledFunction(*CB, Solver)) {
116 auto *BB = CB->getParent();
117 assert(BB && "Unexpected Program State");
118 if (CF->isDeclaration() && mayThrow(*BB))
119 return;
120 if (CF == A.getParent())
121 return;
122 for (auto &Param : CF->args()) {
123 auto *CallArg = CB->getArgOperand(Param.getArgNo());
124 if (CallArg != Def)
125 continue;
126 if (!CallArg)
127 continue;
128
129 analyze(Param);
130 auto &CallAF = getOrCreateArgFlow(Param);
131 DefFlow.mergeAllocSize(CallAF);
132
133 if (!CallAF.isUsedByRet())
134 continue;
135
136 DefUseChains.emplace(&User, DefFlow);
137 }
138 }
139
140 return;
141 }
142
143 if (auto *SI = dyn_cast<StoreInst>(&User)) {
144 // if current user is store instruction,
145 auto *Op0 = SI->getOperand(0);
146 auto *Op1 = SI->getOperand(1);
147 assert(Op0 && Op1 && "Unexpected Program State");
148
149 // if storedDef has not been visited yet and is not an argument,

Callers

nothing calls this directly

Calls 9

getCalledFunctionFunction · 0.85
getAsArrayTypeFunction · 0.85
endMethod · 0.80
mergeAllocSizeMethod · 0.80
isUsedByRetMethod · 0.80
setStructMethod · 0.80
setUsedByRetMethod · 0.80
findMethod · 0.45
getTypeMethod · 0.45

Tested by

no test coverage detected