| 840 | } |
| 841 | |
| 842 | static bool may_be_nonlocal(Value *ptr) { |
| 843 | vector<Value*> todo = { ptr }; |
| 844 | set<Value*> seen; |
| 845 | do { |
| 846 | ptr = todo.back(); |
| 847 | todo.pop_back(); |
| 848 | if (!seen.insert(ptr).second) |
| 849 | continue; |
| 850 | |
| 851 | if (returns_local(*ptr)) |
| 852 | continue; |
| 853 | |
| 854 | if (auto gep = dynamic_cast<GEP*>(ptr)) { |
| 855 | todo.emplace_back(&gep->getPtr()); |
| 856 | continue; |
| 857 | } |
| 858 | |
| 859 | if (auto c = isNoOp(*ptr)) { |
| 860 | todo.emplace_back(c); |
| 861 | continue; |
| 862 | } |
| 863 | |
| 864 | if (auto phi = dynamic_cast<Phi*>(ptr)) { |
| 865 | auto ops = phi->operands(); |
| 866 | todo.insert(todo.end(), ops.begin(), ops.end()); |
| 867 | continue; |
| 868 | } |
| 869 | |
| 870 | if (auto s = dynamic_cast<Select*>(ptr)) { |
| 871 | todo.emplace_back(s->getTrueValue()); |
| 872 | todo.emplace_back(s->getFalseValue()); |
| 873 | continue; |
| 874 | } |
| 875 | return true; |
| 876 | |
| 877 | } while (!todo.empty()); |
| 878 | |
| 879 | return false; |
| 880 | } |
| 881 | |
| 882 | static pair<Value*, uint64_t> collect_gep_offsets(Value &v) { |
| 883 | Value *ptr = &v; |
no test coverage detected