| 116 | } |
| 117 | |
| 118 | uint64_t getFunctionHash ( Function * fun, SimNode * node, Context * context ) { |
| 119 | debug_hash("\n%s\n", fun->getMangledName().c_str()); |
| 120 | SimFnHashVisitor hashV(context); |
| 121 | // append return type and result type |
| 122 | uint64_t resT = fun->result->getSemanticHash(); |
| 123 | hashV.write(&resT, sizeof(uint64_t)); |
| 124 | debug_hash("\nresult <%s> = %" PRIx64 "\n", fun->result->getMangledName().c_str(), resT); |
| 125 | for ( auto & arg : fun->arguments ) { |
| 126 | uint64_t argT = arg->type->getSemanticHash(); |
| 127 | hashV.write(&argT, sizeof(argT)); |
| 128 | debug_hash("arg %s <%s> = %" PRIx64 "\n", arg->type->getMangledName().c_str(), arg->name.c_str(), argT); |
| 129 | } |
| 130 | |
| 131 | // append code |
| 132 | node->visit(hashV); |
| 133 | if ( fun->aotHashDeppendsOnArguments ) { |
| 134 | for ( auto & arg : fun->arguments ) { |
| 135 | hashV.write(arg->name.c_str()); |
| 136 | if ( arg->init ) { |
| 137 | TextWriter tw; |
| 138 | tw << *(arg->init); |
| 139 | hashV.write(tw.str().c_str()); |
| 140 | } |
| 141 | } |
| 142 | } |
| 143 | uint64_t res = hashV.getHash(); |
| 144 | debug_hash("\n%s = %" PRIx64 "\n", fun->getMangledName().c_str(), res); |
| 145 | return res; |
| 146 | } |
| 147 | |
| 148 | struct DependencyCollector { |
| 149 | void collect ( const Function * fun ) { |
no test coverage detected