| 27 | namespace util { |
| 28 | |
| 29 | void sym_exec_init(State &s) { |
| 30 | Function &f = const_cast<Function&>(s.getFn()); |
| 31 | |
| 32 | // global constants need to be created in the right order so they get the |
| 33 | // first bids in source, and the last in target |
| 34 | set<const Value*> seen_inits; |
| 35 | for (const auto &v : f.getConstants()) { |
| 36 | if (auto gv = dynamic_cast<const GlobalVariable*>(&v)) { |
| 37 | if (gv->isConst() == s.isSource()) { |
| 38 | s.exec(v); |
| 39 | seen_inits.emplace(&v); |
| 40 | } |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | // add constants & inputs to State table first of all |
| 45 | for (auto &l : { f.getConstants(), f.getInputs(), f.getUndefs() }) { |
| 46 | for (const auto &v : l) { |
| 47 | if (!seen_inits.count(&v)) |
| 48 | s.exec(v); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | if (f.getFirstBB().getName() == "#init") { |
| 53 | s.startBB(f.getFirstBB()); |
| 54 | for (auto &i : f.getFirstBB().instrs()) { |
| 55 | sym_exec_instr(s, i); |
| 56 | } |
| 57 | } |
| 58 | s.finishInitializer(); |
| 59 | |
| 60 | s.exec(Value::voidVal); |
| 61 | } |
| 62 | |
| 63 | void sym_exec(State &s) { |
| 64 | sym_exec_init(s); |
no test coverage detected