diff options
Diffstat (limited to 'llvm/tools/llc/llc.cpp')
| -rw-r--r-- | llvm/tools/llc/llc.cpp | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/llvm/tools/llc/llc.cpp b/llvm/tools/llc/llc.cpp index c07f4e66486c..8d82d78b15b5 100644 --- a/llvm/tools/llc/llc.cpp +++ b/llvm/tools/llc/llc.cpp @@ -36,6 +36,7 @@ #include "llvm/IR/Verifier.h" #include "llvm/IRReader/IRReader.h" #include "llvm/InitializePasses.h" +#include "llvm/MC/MCTargetOptionsCommandFlags.h" #include "llvm/MC/SubtargetFeature.h" #include "llvm/MC/TargetRegistry.h" #include "llvm/Pass.h" @@ -117,12 +118,10 @@ static cl::opt<bool> // Determine optimization level. static cl::opt<char> -OptLevel("O", - cl::desc("Optimization level. [-O0, -O1, -O2, or -O3] " - "(default = '-O2')"), - cl::Prefix, - cl::ZeroOrMore, - cl::init(' ')); + OptLevel("O", + cl::desc("Optimization level. [-O0, -O1, -O2, or -O3] " + "(default = '-O2')"), + cl::Prefix, cl::init(' ')); static cl::opt<std::string> TargetTriple("mtriple", cl::desc("Override target triple for module")); @@ -212,7 +211,7 @@ static RunPassOption RunPassOpt; static cl::opt<RunPassOption, true, cl::parser<std::string>> RunPass( "run-pass", cl::desc("Run compiler only for specified passes (comma separated list)"), - cl::value_desc("pass-name"), cl::ZeroOrMore, cl::location(RunPassOpt)); + cl::value_desc("pass-name"), cl::location(RunPassOpt)); static int compileModule(char **, LLVMContext &); @@ -369,6 +368,7 @@ int main(int argc, char **argv) { initializeHardwareLoopsPass(*Registry); initializeTransformUtils(*Registry); initializeReplaceWithVeclibLegacyPass(*Registry); + initializeTLSVariableHoistLegacyPassPass(*Registry); // Initialize debugging passes. initializeScavengerTestPass(*Registry); @@ -501,14 +501,26 @@ static int compileModule(char **argv, LLVMContext &Context) { TargetMachine::parseBinutilsVersion(BinutilsVersion); Options.DisableIntegratedAS = NoIntegratedAssembler; Options.MCOptions.ShowMCEncoding = ShowMCEncoding; - Options.MCOptions.MCUseDwarfDirectory = DwarfDirectory; Options.MCOptions.AsmVerbose = AsmVerbose; Options.MCOptions.PreserveAsmComments = PreserveComments; Options.MCOptions.IASSearchPaths = IncludeDirs; Options.MCOptions.SplitDwarfFile = SplitDwarfFile; + if (DwarfDirectory.getPosition()) { + Options.MCOptions.MCUseDwarfDirectory = + DwarfDirectory ? MCTargetOptions::EnableDwarfDirectory + : MCTargetOptions::DisableDwarfDirectory; + } else { + // -dwarf-directory is not set explicitly. Some assemblers + // (e.g. GNU as or ptxas) do not support `.file directory' + // syntax prior to DWARFv5. Let the target decide the default + // value. + Options.MCOptions.MCUseDwarfDirectory = + MCTargetOptions::DefaultDwarfDirectory; + } }; Optional<Reloc::Model> RM = codegen::getExplicitRelocModel(); + Optional<CodeModel::Model> CM = codegen::getExplicitCodeModel(); const Target *TheTarget = nullptr; std::unique_ptr<TargetMachine> Target; @@ -535,14 +547,13 @@ static int compileModule(char **argv, LLVMContext &Context) { // On AIX, setting the relocation model to anything other than PIC is // considered a user error. - if (TheTriple.isOSAIX() && RM.hasValue() && *RM != Reloc::PIC_) + if (TheTriple.isOSAIX() && RM && *RM != Reloc::PIC_) reportError("invalid relocation model, AIX only supports PIC", InputFilename); InitializeOptions(TheTriple); Target = std::unique_ptr<TargetMachine>(TheTarget->createTargetMachine( - TheTriple.getTriple(), CPUStr, FeaturesStr, Options, RM, - codegen::getExplicitCodeModel(), OLvl)); + TheTriple.getTriple(), CPUStr, FeaturesStr, Options, RM, CM, OLvl)); assert(Target && "Could not allocate target machine!"); return Target->createDataLayout().getStringRepresentation(); @@ -562,6 +573,10 @@ static int compileModule(char **argv, LLVMContext &Context) { } if (!TargetTriple.empty()) M->setTargetTriple(Triple::normalize(TargetTriple)); + + Optional<CodeModel::Model> CM_IR = M->getCodeModel(); + if (!CM && CM_IR) + Target->setCodeModel(CM_IR.getValue()); } else { TheTriple = Triple(Triple::normalize(TargetTriple)); if (TheTriple.getTriple().empty()) @@ -578,7 +593,7 @@ static int compileModule(char **argv, LLVMContext &Context) { // On AIX, setting the relocation model to anything other than PIC is // considered a user error. - if (TheTriple.isOSAIX() && RM.hasValue() && *RM != Reloc::PIC_) { + if (TheTriple.isOSAIX() && RM && *RM != Reloc::PIC_) { WithColor::error(errs(), argv[0]) << "invalid relocation model, AIX only supports PIC.\n"; return 1; @@ -586,8 +601,7 @@ static int compileModule(char **argv, LLVMContext &Context) { InitializeOptions(TheTriple); Target = std::unique_ptr<TargetMachine>(TheTarget->createTargetMachine( - TheTriple.getTriple(), CPUStr, FeaturesStr, Options, RM, - codegen::getExplicitCodeModel(), OLvl)); + TheTriple.getTriple(), CPUStr, FeaturesStr, Options, RM, CM, OLvl)); assert(Target && "Could not allocate target machine!"); // If we don't have a module then just exit now. We do this down |
