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

Method updateDefault

lib/propanalysis/DirectionAnalyzer.cpp:280–346  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278}
279
280void DirectionAnalyzer::updateDefault(const llvm::Module &M) {
281 if (!Report)
282 return;
283
284 const std::map<Intrinsic::ID, std::map<unsigned, ArgDir>>
285 DefaultIntrinsicMap = {
286 {{Intrinsic::memcpy, {{0, Dir_Out}, {1, Dir_In}, {2, Dir_In}}},
287 {Intrinsic::memmove, {{0, Dir_Out}, {1, Dir_In}, {2, Dir_In}}},
288 {Intrinsic::memset, {{0, Dir_Out}, {1, Dir_In}, {2, Dir_In}}},
289 {Intrinsic::memcpy_element_unordered_atomic,
290 {{0, Dir_Out}, {1, Dir_In}, {2, Dir_In}}},
291 {Intrinsic::memmove_element_unordered_atomic,
292 {{0, Dir_Out}, {1, Dir_In}, {2, Dir_In}}},
293 {Intrinsic::memset_element_unordered_atomic,
294 {{0, Dir_Out}, {1, Dir_In}, {2, Dir_In}}}}};
295 const std::map<std::string, std::map<unsigned, ArgDir>> DefaultNameMap = {
296 {{"memcpy", {{0, Dir_Out}, {1, Dir_In}, {2, Dir_In}}},
297 {"memmove", {{0, Dir_Out}, {1, Dir_In}, {2, Dir_In}}},
298 {"memset", {{0, Dir_Out}, {1, Dir_In}, {2, Dir_In}}},
299 {"memcpy_element_unordered_atomic",
300 {{0, Dir_Out}, {1, Dir_In}, {2, Dir_In}}},
301 {"memmove_element_unordered_atomic",
302 {{0, Dir_Out}, {1, Dir_In}, {2, Dir_In}}},
303 {"memset_element_unordered_atomic",
304 {{0, Dir_Out}, {1, Dir_In}, {2, Dir_In}}}}};
305
306 ManualAllocLoader MAL;
307 for (const auto &F : M) {
308 if (!F.isDeclaration())
309 continue;
310
311 auto IterIntrinsic = DefaultIntrinsicMap.find(F.getIntrinsicID());
312 if (IterIntrinsic != DefaultIntrinsicMap.end())
313 updateDefault(F, IterIntrinsic->second);
314
315 auto IterName = DefaultNameMap.find(F.getName().str());
316 if (IterName != DefaultNameMap.end())
317 updateDefault(F, IterName->second);
318
319 if (MAL.isAllocFunction(F)) {
320 for (auto AllocSizeArg : MAL.getAllocSizeArgNo(F)) {
321 if (AllocSizeArg > F.arg_size())
322 continue;
323
324 std::map<unsigned, ArgDir> Values = {{AllocSizeArg, Dir_In}};
325 updateDefault(F, Values);
326 }
327 continue;
328 }
329
330 if (F.getName() == "free") {
331 std::map<unsigned, ArgDir> Values = {{0, Dir_In}};
332 updateDefault(F, Values);
333 }
334 }
335
336 for (auto Iter : ArgFlowMap) {
337 auto &AF = Iter.second;

Callers

nothing calls this directly

Calls 9

endMethod · 0.80
getAllocSizeArgNoMethod · 0.80
getStateMethod · 0.80
setArgDirMethod · 0.80
setStateMethod · 0.80
findMethod · 0.45
getNameMethod · 0.45
isAllocFunctionMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected