1*00c943a5SGuillaume Chatelet #include "automemcpy/CodeGen.h"
2*00c943a5SGuillaume Chatelet #include "automemcpy/RandomFunctionGenerator.h"
3*00c943a5SGuillaume Chatelet #include <unordered_set>
4*00c943a5SGuillaume Chatelet 
5*00c943a5SGuillaume Chatelet namespace llvm {
6*00c943a5SGuillaume Chatelet namespace automemcpy {
7*00c943a5SGuillaume Chatelet 
generateFunctionDescriptors()8*00c943a5SGuillaume Chatelet std::vector<FunctionDescriptor> generateFunctionDescriptors() {
9*00c943a5SGuillaume Chatelet   std::unordered_set<FunctionDescriptor, FunctionDescriptor::Hasher> Seen;
10*00c943a5SGuillaume Chatelet   std::vector<FunctionDescriptor> FunctionDescriptors;
11*00c943a5SGuillaume Chatelet   RandomFunctionGenerator P;
12*00c943a5SGuillaume Chatelet   while (Optional<FunctionDescriptor> MaybeFD = P.next()) {
13*00c943a5SGuillaume Chatelet     FunctionDescriptor FD = *MaybeFD;
14*00c943a5SGuillaume Chatelet     if (Seen.count(FD)) // FIXME: Z3 sometimes returns twice the same object.
15*00c943a5SGuillaume Chatelet       continue;
16*00c943a5SGuillaume Chatelet     Seen.insert(FD);
17*00c943a5SGuillaume Chatelet     FunctionDescriptors.push_back(std::move(FD));
18*00c943a5SGuillaume Chatelet   }
19*00c943a5SGuillaume Chatelet   return FunctionDescriptors;
20*00c943a5SGuillaume Chatelet }
21*00c943a5SGuillaume Chatelet 
22*00c943a5SGuillaume Chatelet } // namespace automemcpy
23*00c943a5SGuillaume Chatelet } // namespace llvm
24*00c943a5SGuillaume Chatelet 
main(int,char **)25*00c943a5SGuillaume Chatelet int main(int, char **) {
26*00c943a5SGuillaume Chatelet   llvm::automemcpy::Serialize(llvm::outs(),
27*00c943a5SGuillaume Chatelet                               llvm::automemcpy::generateFunctionDescriptors());
28*00c943a5SGuillaume Chatelet }
29