[llvm] 322519e - [llc] Initialize TargetOptions after Triple is available
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 2 11:47:42 PDT 2020
Author: Fangrui Song
Date: 2020-10-02T11:43:40-07:00
New Revision: 322519ee1276cd7cc5f32b3fe335d0b804c8b8c0
URL: https://github.com/llvm/llvm-project/commit/322519ee1276cd7cc5f32b3fe335d0b804c8b8c0
DIFF: https://github.com/llvm/llvm-project/commit/322519ee1276cd7cc5f32b3fe335d0b804c8b8c0.diff
LOG: [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
Added:
Modified:
llvm/tools/llc/llc.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llc/llc.cpp b/llvm/tools/llc/llc.cpp
index 95f2963ecbd6..98a2735887c0 100644
--- a/llvm/tools/llc/llc.cpp
+++ b/llvm/tools/llc/llc.cpp
@@ -424,14 +424,17 @@ static int compileModule(char **argv, LLVMContext &Context) {
case '3': OLvl = CodeGenOpt::Aggressive; break;
}
- TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags();
- Options.DisableIntegratedAS = NoIntegratedAssembler;
- Options.MCOptions.ShowMCEncoding = ShowMCEncoding;
- Options.MCOptions.MCUseDwarfDirectory = EnableDwarfDirectory;
- Options.MCOptions.AsmVerbose = AsmVerbose;
- Options.MCOptions.PreserveAsmComments = PreserveComments;
- Options.MCOptions.IASSearchPaths = IncludeDirs;
- Options.MCOptions.SplitDwarfFile = SplitDwarfFile;
+ TargetOptions Options;
+ auto InitializeOptions = [&](const Triple &TheTriple) {
+ Options = codegen::InitTargetOptionsFromCodeGenFlags();
+ Options.DisableIntegratedAS = NoIntegratedAssembler;
+ Options.MCOptions.ShowMCEncoding = ShowMCEncoding;
+ Options.MCOptions.MCUseDwarfDirectory = EnableDwarfDirectory;
+ Options.MCOptions.AsmVerbose = AsmVerbose;
+ 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));
More information about the llvm-commits
mailing list