diff options
Diffstat (limited to 'lib/CodeGen/BackendUtil.cpp')
-rw-r--r-- | lib/CodeGen/BackendUtil.cpp | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/lib/CodeGen/BackendUtil.cpp b/lib/CodeGen/BackendUtil.cpp index 9897b1b..1264473 100644 --- a/lib/CodeGen/BackendUtil.cpp +++ b/lib/CodeGen/BackendUtil.cpp @@ -30,6 +30,7 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetRegistry.h" +#include "llvm/Transforms/Instrumentation.h" using namespace clang; using namespace llvm; @@ -108,9 +109,9 @@ void EmitAssemblyHelper::CreatePasses() { OptLevel = 0; Inlining = CodeGenOpts.NoInlining; } - + FunctionPassManager *FPM = getPerFunctionPasses(); - + TargetLibraryInfo *TLI = new TargetLibraryInfo(Triple(TheModule->getTargetTriple())); if (!CodeGenOpts.SimplifyLibCalls) @@ -133,8 +134,10 @@ void EmitAssemblyHelper::CreatePasses() { // // FIXME: Derive these constants in a principled fashion. unsigned Threshold = 225; - if (CodeGenOpts.OptimizeSize) + if (CodeGenOpts.OptimizeSize == 1) //-Os Threshold = 75; + else if (CodeGenOpts.OptimizeSize == 2) //-Oz + Threshold = 25; else if (OptLevel > 2) Threshold = 275; InliningPass = createFunctionInliningPass(Threshold); @@ -146,12 +149,19 @@ void EmitAssemblyHelper::CreatePasses() { } PassManager *MPM = getPerModulePasses(); - + TLI = new TargetLibraryInfo(Triple(TheModule->getTargetTriple())); if (!CodeGenOpts.SimplifyLibCalls) TLI->disableAllFunctions(); MPM->add(TLI); + if (CodeGenOpts.EmitGcovArcs || CodeGenOpts.EmitGcovNotes) { + MPM->add(createGCOVProfilerPass(CodeGenOpts.EmitGcovNotes, + CodeGenOpts.EmitGcovArcs)); + if (!CodeGenOpts.DebugInfo) + MPM->add(createStripSymbolsPass(true)); + } + // For now we always create per module passes. llvm::createStandardModulePasses(MPM, OptLevel, CodeGenOpts.OptimizeSize, @@ -190,7 +200,7 @@ bool EmitAssemblyHelper::AddEmitPasses(BackendAction Action, } // Set float ABI type. - if (CodeGenOpts.FloatABI == "soft") + if (CodeGenOpts.FloatABI == "soft" || CodeGenOpts.FloatABI == "softfp") llvm::FloatABIType = llvm::FloatABI::Soft; else if (CodeGenOpts.FloatABI == "hard") llvm::FloatABIType = llvm::FloatABI::Hard; @@ -248,6 +258,8 @@ bool EmitAssemblyHelper::AddEmitPasses(BackendAction Action, } if (llvm::TimePassesIsEnabled) BackendArgs.push_back("-time-passes"); + for (unsigned i = 0, e = CodeGenOpts.BackendOptions.size(); i != e; ++i) + BackendArgs.push_back(CodeGenOpts.BackendOptions[i].c_str()); BackendArgs.push_back(0); llvm::cl::ParseCommandLineOptions(BackendArgs.size() - 1, const_cast<char **>(&BackendArgs[0])); @@ -266,6 +278,10 @@ bool EmitAssemblyHelper::AddEmitPasses(BackendAction Action, if (CodeGenOpts.RelaxAll) TM->setMCRelaxAll(true); + if (CodeGenOpts.SaveTempLabels) + TM->setMCSaveTempLabels(true); + if (CodeGenOpts.NoDwarf2CFIAsm) + TM->setMCUseCFI(false); // Create the code generator passes. PassManager *PM = getCodeGenPasses(); @@ -319,6 +335,9 @@ void EmitAssemblyHelper::EmitAssembly(BackendAction Action, raw_ostream *OS) { return; } + // Before executing passes, print the final values of the LLVM options. + cl::PrintOptionValues(); + // Run passes. For now we do all passes at once, but eventually we // would like to have the option of streaming code generation. |