1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 04:32:44 +01:00

[llc] Initialize TargetOptions after Triple is available

Some targets have different defaults. This patch defers initialization of `TargetOptions` so that a future patch can pass `TargetOptions` to `InitTargetOptionsFromCodeGenFlags`

Reviewed By: jasonliu

Differential Revision: https://reviews.llvm.org/D88748
This commit is contained in:
Fangrui Song 2020-10-02 11:43:17 -07:00
parent a827dbae48
commit 3f6a90dc9a

View File

@ -424,7 +424,9 @@ static int compileModule(char **argv, LLVMContext &Context) {
case '3': OLvl = CodeGenOpt::Aggressive; break;
}
TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags();
TargetOptions Options;
auto InitializeOptions = [&](const Triple &TheTriple) {
Options = codegen::InitTargetOptionsFromCodeGenFlags();
Options.DisableIntegratedAS = NoIntegratedAssembler;
Options.MCOptions.ShowMCEncoding = ShowMCEncoding;
Options.MCOptions.MCUseDwarfDirectory = EnableDwarfDirectory;
@ -432,6 +434,7 @@ static int compileModule(char **argv, LLVMContext &Context) {
Options.MCOptions.PreserveAsmComments = PreserveComments;
Options.MCOptions.IASSearchPaths = IncludeDirs;
Options.MCOptions.SplitDwarfFile = SplitDwarfFile;
};
Optional<Reloc::Model> RM = codegen::getExplicitRelocModel();
@ -466,6 +469,7 @@ static int compileModule(char **argv, LLVMContext &Context) {
exit(1);
}
InitializeOptions(TheTriple);
Target = std::unique_ptr<TargetMachine>(TheTarget->createTargetMachine(
TheTriple.getTriple(), CPUStr, FeaturesStr, Options, RM,
codegen::getExplicitCodeModel(), OLvl));
@ -510,6 +514,7 @@ static int compileModule(char **argv, LLVMContext &Context) {
return 1;
}
InitializeOptions(TheTriple);
Target = std::unique_ptr<TargetMachine>(TheTarget->createTargetMachine(
TheTriple.getTriple(), CPUStr, FeaturesStr, Options, RM,
codegen::getExplicitCodeModel(), OLvl));