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

Class FindTarget

lib/rootdefanalysis/RDTarget.cpp:13–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11namespace {
12
13class FindTarget {
14
15public:
16 std::set<std::pair<Value *, std::vector<unsigned>>>
17 find(Value &Target, RDSpace *Space = nullptr) {
18
19 std::set<std::pair<Value *, std::vector<unsigned>>> Result;
20
21 init();
22 push(Target);
23
24 while (auto CurNode = pop()) {
25 if (auto *LI = dyn_cast<LoadInst>(CurNode->Target)) {
26 push(*LI->getPointerOperand(), CurNode->Indices);
27 if (!Space)
28 continue;
29
30 for (auto *Alias : Space->getAliases(*LI)) {
31 if (Space->dominates(*LI, *Alias))
32 continue;
33
34 if (auto *SI = dyn_cast<StoreInst>(Alias)) {
35 push(*SI->getValueOperand(), CurNode->Indices);
36 continue;
37 }
38
39 push(*Alias, CurNode->Indices);
40 }
41 continue;
42 }
43
44 if (auto *CI = dyn_cast<CastInst>(CurNode->Target)) {
45 push(*CI->getOperand(0), CurNode->Indices);
46 continue;
47 }
48
49 if (auto *GEPI = dyn_cast<GetElementPtrInst>(CurNode->Target)) {
50 auto Indices = memoryIndices(*GEPI);
51 CurNode->Indices.insert(CurNode->Indices.begin(), Indices.begin(),
52 Indices.end());
53 push(*GEPI->getOperand(0), CurNode->Indices);
54 continue;
55 }
56
57 if (auto *CE = dyn_cast<ConstantExpr>(CurNode->Target)) {
58 if (CE->isCast()) {
59 push(*CE->getOperand(0), CurNode->Indices);
60 continue;
61 } else if (CE->isGEPWithNoNotionalOverIndexing()) {
62 auto Indices = memoryIndices(*CE);
63 CurNode->Indices.insert(CurNode->Indices.begin(), Indices.begin(),
64 Indices.end());
65 push(*CE->getOperand(0), CurNode->Indices);
66 continue;
67 }
68 }
69
70 Result.emplace(CurNode->Target, CurNode->Indices);

Callers 1

createMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected