MCPcopy Create free account
hub / github.com/AliveToolkit/alive2 / removeUnused

Function removeUnused

ir/function.cpp:399–421  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

397
398template <typename T>
399static bool removeUnused(T &data, const Function::UsersTy &users,
400 const vector<string_view> &src_glbs) {
401 bool changed = false;
402 for (auto I = data.begin(); I != data.end(); ) {
403 if (users.count(I->get())) {
404 ++I;
405 continue;
406 }
407
408 // don't delete glbs in target that are used in src
409 if (auto gv = dynamic_cast<GlobalVariable*>(I->get())) {
410 auto name = string_view(gv->getName()).substr(1);
411 if (find(src_glbs.begin(), src_glbs.end(), name) != src_glbs.end()) {
412 ++I;
413 continue;
414 }
415 }
416
417 I = data.erase(I);
418 changed = true;
419 }
420 return changed;
421}
422
423bool Function::removeUnusedStuff(const UsersTy &users,
424 const vector<string_view> &src_glbs) {

Callers 1

removeUnusedStuffMethod · 0.85

Calls 3

beginMethod · 0.45
endMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected