Switch the TargetMachine back to being IGM-specific instead of global to the IRGenerator.

My understanding is that this *should* be read-only, but there
are test cases that are failing that suggest it might not be.
This commit is contained in:
John McCall
2016-04-27 10:38:10 -07:00
parent 560f71fa5d
commit 8e3151f451
3 changed files with 64 additions and 48 deletions

View File

@@ -114,19 +114,22 @@ static clang::CodeGenerator *createClangCodeGenerator(ASTContext &Context,
return ClangCodeGen;
}
IRGenModule::IRGenModule(IRGenerator &irgen, SourceFile *SF,
ASTContext &Context,
IRGenModule::IRGenModule(IRGenerator &irgen,
std::unique_ptr<llvm::TargetMachine> &&target,
SourceFile *SF,
llvm::LLVMContext &LLVMContext,
StringRef ModuleName,
StringRef OutputFilename)
: Context(Context),
: IRGen(irgen),
Context(irgen.SIL.getASTContext()),
ClangCodeGen(createClangCodeGenerator(Context, LLVMContext,
irgen.Opts, ModuleName)),
Module(*ClangCodeGen->GetModule()),
LLVMContext(Module.getContext()),
DataLayout(irgen.TargetMachine->createDataLayout()),
DataLayout(target->createDataLayout()),
Triple(Context.LangOpts.Target),
OutputFilename(OutputFilename), IRGen(irgen),
TargetMachine(std::move(target)),
OutputFilename(OutputFilename),
TargetInfo(SwiftTargetInfo::get(*this)),
DebugInfo(0), ModuleHash(nullptr),
ObjCInterop(Context.LangOpts.EnableObjCInterop),