Revert "Refactor SourceInfo into Source."
This reverts commit 4ce024bcff99bb154f44a73f4cf6201a0fe75917.
diff --git a/lib/ExecutionEngine/Compiler.cpp b/lib/ExecutionEngine/Compiler.cpp
index 100f54b..58a49c5 100644
--- a/lib/ExecutionEngine/Compiler.cpp
+++ b/lib/ExecutionEngine/Compiler.cpp
@@ -226,27 +226,27 @@
mRSExecutable(NULL),
mpSymbolLookupFn(NULL),
mpSymbolLookupContext(NULL),
- mModule(NULL) {
+ mModule(NULL),
+ mHasLinked(false) /* Turn off linker */ {
llvm::remove_fatal_error_handler();
llvm::install_fatal_error_handler(LLVMErrorHandler, &mError);
return;
}
-int Compiler::readModule(llvm::Module &pModule) {
- mModule = &pModule;
- if (pModule.getMaterializer() != NULL) {
- // A module with non-null materializer means that it is a lazy-load module.
- // Materialize it now via invoking MaterializeAllPermanently(). This
- // function returns false when the materialization is successful.
- if (pModule.MaterializeAllPermanently(&mError)) {
- setError("Failed to materialize the module `" +
- pModule.getModuleIdentifier() + "'! (" + mError + ")");
- mModule = NULL;
- }
+
+int Compiler::linkModule(llvm::Module *moduleWith) {
+ if (llvm::Linker::LinkModules(mModule, moduleWith,
+ llvm::Linker::PreserveSource,
+ &mError) != 0) {
+ return hasError();
}
+
+ // Everything for linking should be settled down here with no error occurs
+ mHasLinked = true;
return hasError();
}
+
int Compiler::compile(const CompilerOption &option) {
llvm::Target const *Target = NULL;
llvm::TargetData *TD = NULL;
@@ -390,7 +390,7 @@
runInternalPasses(ForEachNameList, ForEachSigList);
// Perform link-time optimization if we have multiple modules
- if (option.RunLTO) {
+ if (mHasLinked) {
runLTO(new llvm::TargetData(*TD), ExportSymbols, CodeGenOptLevel);
}