]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
1. renamed libcody lto functions to invoke functions
authorJohn Ravi <jjravi@ncsu.edu>
Sat, 29 Aug 2020 07:06:28 +0000 (07:06 +0000)
committerJohn Ravi <jjravi@ncsu.edu>
Sat, 29 Aug 2020 07:06:28 +0000 (07:06 +0000)
2. invoke (send to libcody) all the lto trans commands at once

gcc/lto-wrapper.c
gcc/mapper-resolver.cc
gcc/mapper.h

index 60ed3192c86d1ad1640c2708994523dcf8bf7e18..516c6217c29c807a6ca8687b32e90a7655352428 100644 (file)
@@ -1919,6 +1919,8 @@ cont:
        }
 
     auto *mapper = get_mapper (main_source_loc);
+    mapper->Cork();
+
       /* Execute the LTRANS stage for each input file (or prepare a
         makefile to invoke this in parallel).  */
       for (i = 0; i < nr; ++i)
@@ -1962,55 +1964,42 @@ cont:
            }
          else
            {
-        //fprintf(stderr, "\tRAVI PRINT: %s ", new_argv[0]);
-        mapper->Cork();
-
         // TODO: better way to figure out the number of arguments?
         for (j = 1; new_argv[j] != NULL; ++j);
         fprintf(stderr, "argc: %d\n", j);
 
-        //std::vector<const char*> v_new_argv(new_argv, new_argv + j);
-        //mapper->LTOCompile(v_new_argv);
-        mapper->LTOCompile(new_argv, j);
-        const char **arg_it = new_argv + 1;
-
-        while(*arg_it != NULL) 
-        {
-          //fprintf(stderr, "\tRAVI PRINT: %s\n", *arg_it);
-          fprintf(stderr, " \'%s\' ", *arg_it);
-          //mapper->LTOCompile(*arg_it);
-          arg_it++;
-        }
-        ////fprintf(stderr, "\n");
-        auto response = mapper->Uncork();
-        auto r_iter = response.begin ();
-
-        while(r_iter != response.end()) {
-          Cody::Packet const &p = *r_iter;
-
-          if(p.GetCode() == Cody::Client::PC_LTO_COMPILED) {
-            if(strcmp(p.GetString().c_str(), "success") == 0) {
-              // fprintf(stderr, "\tlto compilation succeeded\n");
-            }
-            else {
-              fprintf(stderr, "\tlto compilation failure message: %s\n", p.GetString().c_str());
-            }
-          }
-          else {
-            fprintf(stderr, "\tlto compilation unknown failure\n");
-          }
-
-          ++r_iter;
-        }
-
-        //fprintf(stderr, "\tRAVI PRINT: %s\n", new_argv[0]);
-             //fork_execute (new_argv[0], CONST_CAST (char **, new_argv),
-                         //  true);
-             maybe_unlink (input_name);
+        mapper->InvokeSubProcess(new_argv, j);
+
+        // TODO: unlink input file somewhere
+                               // maybe_unlink (input_name);
            }
 
          output_names[i] = output_name;
        }
+
+  auto response = mapper->Uncork();
+  auto r_iter = response.begin ();
+
+  while(r_iter != response.end()) {
+    Cody::Packet const &p = *r_iter;
+
+    if(p.GetCode() == Cody::Client::PC_INVOKED) {
+      if(strcmp(p.GetString().c_str(), "success") == 0) {
+        fprintf(stderr, "\tlto compilation succeeded\n");
+      }
+      else {
+        fprintf(stderr, "\tlto compilation failure message: %s\n", p.GetString().c_str());
+      }
+    }
+    else {
+      fprintf(stderr, "\tlto compilation unknown failure\n");
+    }
+
+    ++r_iter;
+  }
+
+  fprintf(stderr, "\n");
+
       if (parallel)
        {
          struct pex_obj *pex;
index 35de17d1db20b19e89e0832105c10807812b0c57..d8e1b57afc7982c7f70cf8e114b3b6b202891cba 100644 (file)
@@ -244,14 +244,14 @@ module_resolver::IncludeTranslateRequest (Cody::Server *s,
   return 0;
 }
 
-int module_resolver::LTOCompileRequest (Cody::Server *s, std::vector<std::string> &args) {
+int module_resolver::InvokeSubProcessRequest (Cody::Server *s, std::vector<std::string> &args) {
   char **new_argv = (char **)malloc((args.size()) * sizeof(char *));
   new_argv[args.size()-1] = NULL;
 
   int i = 0;
   for (std::vector<std::string>::iterator arg = args.begin() ; arg != args.end(); ++arg, ++i) {
 
-    // ignore "LTO-COMPILE"
+    // ignore "INVOKE"
     if(i == 0) continue;
     //new_argv[i++] = (char *)malloc(args[i].length() * sizeof(char)); 
 
@@ -265,7 +265,7 @@ int module_resolver::LTOCompileRequest (Cody::Server *s, std::vector<std::string
   fork_execute (new_argv[0], new_argv, true);
 
   // TODO: send back a compile status response
-  s->LTOResponse("success");
+  s->InvokedResponse("success");
   return 0;
 }
 
index 306ee5cccb60a864c8d3b2f8df14b98aa5971cc0..49118d123bc15c63bcb3fac27144cbe834c00f59 100644 (file)
@@ -78,7 +78,7 @@ public:
   virtual int IncludeTranslateRequest (Cody::Server *s, std::string &include)
     override;
 
-  virtual int LTOCompileRequest (Cody::Server *s, std::vector<std::string> &args)
+  virtual int InvokeSubProcessRequest (Cody::Server *s, std::vector<std::string> &args)
     override;
 
 private: