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

Method findRelatedArg

lib/propanalysis/ArgFlow.cpp:339–378  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

337void ArgFlow::setArgDir(unsigned ArgDir) { Direction = ArgDir; }
338
339Argument *ArgFlow::findRelatedArg(Value &V, std::set<Value *> &Visit) {
340 if (Visit.find(&V) != Visit.end() || isa<Constant>(&V) || isa<CmpInst>(&V) ||
341 isa<GetElementPtrInst>(&V)) {
342 return nullptr;
343 } else if (auto *I = dyn_cast<Instruction>(&V)) {
344 if (I->isTerminator()) {
345 return nullptr;
346 }
347 }
348 Visit.insert(&V);
349
350 if (auto *A = dyn_cast<Argument>(&V))
351 return A;
352
353 // traverse Operands and Users
354 if (auto *I = dyn_cast<Instruction>(&V)) {
355 if (isUnionFieldAccess(I) || isa<CallBase>(I))
356 return nullptr;
357
358 for (auto *O : I->operand_values()) {
359 if (isa<Constant>(O))
360 continue;
361
362 if (auto *RelatedArg = findRelatedArg(*O, Visit))
363 return RelatedArg;
364 }
365 }
366
367 // FIXME: it is workaround to reverse order of users
368 std::list<User *> users;
369 for (auto *U : V.users())
370 users.push_front(U);
371
372 for (auto *U : users) {
373 if (auto *RelatedArg = findRelatedArg(*U, Visit))
374 return RelatedArg;
375 }
376
377 return nullptr;
378}
379
380void ArgFlow::setAllocSize() { IsAllocSize = true; }
381

Callers

nothing calls this directly

Calls 3

isUnionFieldAccessFunction · 0.85
endMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected