Remove StringMap::GetOrCreateValue in favor of StringMap::insert
[oota-llvm.git] / tools / lto / lto.cpp
index b401f9a7f1916cf6d9454fd8af39aeb2e4b01551..ef37c90ba3b4350fa109838fc1fd65622fabd1c6 100644 (file)
@@ -32,6 +32,10 @@ static cl::opt<bool>
 DisableGVNLoadPRE("disable-gvn-loadpre", cl::init(false),
   cl::desc("Do not run the GVN load PRE pass"));
 
+static cl::opt<bool>
+DisableLTOVectorization("disable-lto-vectorization", cl::init(false),
+  cl::desc("Do not run loop or slp vectorization during LTO"));
+
 // Holds most recent error string.
 // *** Not thread safe ***
 static std::string sLastErrorString;
@@ -146,6 +150,24 @@ lto_module_t lto_module_create_from_memory_with_path(const void* mem,
       LTOModule::createFromBuffer(mem, length, Options, sLastErrorString, path));
 }
 
+lto_module_t lto_module_create_in_local_context(const void *mem, size_t length,
+                                                const char *path) {
+  lto_initialize();
+  llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
+  return wrap(LTOModule::createInLocalContext(mem, length, Options,
+                                              sLastErrorString, path));
+}
+
+lto_module_t lto_module_create_in_codegen_context(const void *mem,
+                                                  size_t length,
+                                                  const char *path,
+                                                  lto_code_gen_t cg) {
+  lto_initialize();
+  llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
+  return wrap(LTOModule::createInContext(mem, length, Options, sLastErrorString,
+                                         path, &unwrap(cg)->getContext()));
+}
+
 void lto_module_dispose(lto_module_t mod) { delete unwrap(mod); }
 
 const char* lto_module_get_target_triple(lto_module_t mod) {
@@ -205,7 +227,7 @@ lto_code_gen_t lto_codegen_create(void) {
 void lto_codegen_dispose(lto_code_gen_t cg) { delete unwrap(cg); }
 
 bool lto_codegen_add_module(lto_code_gen_t cg, lto_module_t mod) {
-  return !unwrap(cg)->addModule(unwrap(mod), sLastErrorString);
+  return !unwrap(cg)->addModule(unwrap(mod));
 }
 
 bool lto_codegen_set_debug_model(lto_code_gen_t cg, lto_debug_model debug) {
@@ -222,10 +244,6 @@ void lto_codegen_set_cpu(lto_code_gen_t cg, const char *cpu) {
   return unwrap(cg)->setCpu(cpu);
 }
 
-void lto_codegen_set_attr(lto_code_gen_t cg, const char *attr) {
-  return unwrap(cg)->setAttr(attr);
-}
-
 void lto_codegen_set_assembler_path(lto_code_gen_t cg, const char *path) {
   // In here only for backwards compatibility. We use MC now.
 }
@@ -256,7 +274,8 @@ const void *lto_codegen_compile(lto_code_gen_t cg, size_t *length) {
     parsedOptions = true;
   }
   return unwrap(cg)->compile(length, DisableOpt, DisableInline,
-                             DisableGVNLoadPRE, sLastErrorString);
+                             DisableGVNLoadPRE, DisableLTOVectorization,
+                             sLastErrorString);
 }
 
 bool lto_codegen_compile_to_file(lto_code_gen_t cg, const char **name) {
@@ -265,8 +284,9 @@ bool lto_codegen_compile_to_file(lto_code_gen_t cg, const char **name) {
     lto_add_attrs(cg);
     parsedOptions = true;
   }
-  return !unwrap(cg)->compile_to_file(name, DisableOpt, DisableInline,
-                                      DisableGVNLoadPRE, sLastErrorString);
+  return !unwrap(cg)->compile_to_file(
+      name, DisableOpt, DisableInline, DisableGVNLoadPRE,
+      DisableLTOVectorization, sLastErrorString);
 }
 
 void lto_codegen_debug_options(lto_code_gen_t cg, const char *opt) {