Move command line options to the users of libLTO. Fixes --enable-shared build.

Patch by Richard Sandiford.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191680 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2013-09-30 16:39:19 +00:00
parent 4b5205d2a3
commit c13c9e5a9d
6 changed files with 185 additions and 176 deletions

View File

@@ -39,6 +39,7 @@
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/Linker.h"
#include "llvm/Target/TargetOptions.h"
#include <string>
#include <vector>
@@ -64,6 +65,7 @@ struct LTOCodeGenerator {
// Merge given module, return true on success.
bool addModule(struct LTOModule*, std::string &errMsg);
void setTargetOptions(llvm::TargetOptions options);
void setDebugInfo(lto_debug_model);
void setCodePICModel(lto_codegen_model);
@@ -90,7 +92,11 @@ struct LTOCodeGenerator {
// Do not try to remove the object file in LTOCodeGenerator's destructor
// as we don't who (LTOCodeGenerator or the obj file) will last longer.
//
bool compile_to_file(const char **name, std::string &errMsg);
bool compile_to_file(const char **name,
bool disableOpt,
bool disableInline,
bool disableGVNLoadPRE,
std::string &errMsg);
// As with compile_to_file(), this function compiles the merged module into
// single object file. Instead of returning the object-file-path to the caller
@@ -98,12 +104,20 @@ struct LTOCodeGenerator {
// caller. This function should delete intermediate object file once its content
// is brought to memory. Return NULL if the compilation was not successful.
//
const void *compile(size_t *length, std::string &errMsg);
const void *compile(size_t *length,
bool disableOpt,
bool disableInline,
bool disableGVNLoadPRE,
std::string &errMsg);
private:
void initializeLTOPasses();
bool generateObjectFile(llvm::raw_ostream &out, std::string &errMsg);
bool generateObjectFile(llvm::raw_ostream &out,
bool disableOpt,
bool disableInline,
bool disableGVNLoadPRE,
std::string &errMsg);
void applyScopeRestrictions();
void applyRestriction(llvm::GlobalValue &GV,
std::vector<const char*> &MustPreserveList,
@@ -125,6 +139,7 @@ private:
std::vector<char *> CodegenOptions;
std::string MCpu;
std::string NativeObjectPath;
llvm::TargetOptions Options;
};
#endif // LTO_CODE_GENERATOR_H