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

Method visitCallBase

lib/indcallsolver/CustomCVPPass.cpp:275–315  ·  view source on GitHub ↗

Handle call sites. The state of a called function's formal arguments is the merge of the argument state with the call sites corresponding actual argument state. The call site state is the merge of the call site state with the returned value state of the called function.

Source from the content-addressed store, hash-verified

273 /// argument state. The call site state is the merge of the call site state
274 /// with the returned value state of the called function.
275 void visitCallBase(CallBase &CB,
276 DenseMap<CVPLatticeKey, CVPLatticeVal> &ChangedValues,
277 SparseSolver<CVPLatticeKey, CVPLatticeVal> &SS) {
278 Function *F = util::getCalledFunction(CB);
279 auto RegI = CVPLatticeKey(&CB, IPOGrouping::Register);
280
281 // If this is an indirect call, save it so we can quickly revisit it when
282 // attaching metadata.
283 if (!F)
284 IndirectCalls.insert(&CB);
285
286 // If we can't track the function's return values, there's nothing to do.
287 if (!F || !canTrackReturnsInterprocedurally(F)) {
288 // Void return, No need to create and update CVPLattice state as no one
289 // can use it.
290 if (CB.getType()->isVoidTy())
291 return;
292 ChangedValues[RegI] = getOverdefinedVal();
293 return;
294 }
295
296 // Inform the solver that the called function is executable, and perform
297 // the merges for the arguments and return value.
298 SS.MarkBlockExecutable(&F->front());
299 auto RetF = CVPLatticeKey(F, IPOGrouping::Return);
300 for (Argument &A : F->args()) {
301 auto RegFormal = CVPLatticeKey(&A, IPOGrouping::Register);
302 auto RegActual =
303 CVPLatticeKey(CB.getArgOperand(A.getArgNo()), IPOGrouping::Register);
304 ChangedValues[RegFormal] =
305 MergeValues(SS.getValueState(RegFormal), SS.getValueState(RegActual));
306 }
307
308 // Void return, No need to create and update CVPLattice state as no one can
309 // use it.
310 if (CB.getType()->isVoidTy())
311 return;
312
313 ChangedValues[RegI] =
314 MergeValues(SS.getValueState(RegI), SS.getValueState(RetF));
315 }
316
317 /// Handle select instructions. The select instruction state is the merge the
318 /// true and false value states.

Callers

nothing calls this directly

Calls 2

getCalledFunctionFunction · 0.85
getTypeMethod · 0.45

Tested by

no test coverage detected