diff options
Diffstat (limited to 'lib/CodeGen/LLVMTargetMachine.cpp')
| -rw-r--r-- | lib/CodeGen/LLVMTargetMachine.cpp | 33 | 
1 files changed, 24 insertions, 9 deletions
diff --git a/lib/CodeGen/LLVMTargetMachine.cpp b/lib/CodeGen/LLVMTargetMachine.cpp index 278de0269b6b..fd442db27a27 100644 --- a/lib/CodeGen/LLVMTargetMachine.cpp +++ b/lib/CodeGen/LLVMTargetMachine.cpp @@ -67,6 +67,9 @@ static cl::opt<bool> VerifyMachineCode("verify-machineinstrs", cl::Hidden,      cl::desc("Verify generated machine code"),      cl::init(getenv("LLVM_VERIFY_MACHINEINSTRS")!=NULL)); +static cl::opt<bool> EnableMachineCSE("machine-cse", cl::Hidden, +    cl::desc("Enable Machine CSE")); +  static cl::opt<cl::boolOrDefault>  AsmVerbose("asm-verbose", cl::desc("Add comments to directives."),             cl::init(cl::BOU_UNSET)); @@ -115,9 +118,10 @@ LLVMTargetMachine::setCodeModelForStatic() {  bool LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,                                              formatted_raw_ostream &Out,                                              CodeGenFileType FileType, -                                            CodeGenOpt::Level OptLevel) { +                                            CodeGenOpt::Level OptLevel, +                                            bool DisableVerify) {    // Add common CodeGen passes. -  if (addCommonCodeGenPasses(PM, OptLevel)) +  if (addCommonCodeGenPasses(PM, OptLevel, DisableVerify))      return true;    OwningPtr<MCContext> Context(new MCContext()); @@ -193,12 +197,13 @@ bool LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,  ///  bool LLVMTargetMachine::addPassesToEmitMachineCode(PassManagerBase &PM,                                                     JITCodeEmitter &JCE, -                                                   CodeGenOpt::Level OptLevel) { +                                                   CodeGenOpt::Level OptLevel, +                                                   bool DisableVerify) {    // Make sure the code model is set.    setCodeModelForJIT();    // Add common CodeGen passes. -  if (addCommonCodeGenPasses(PM, OptLevel)) +  if (addCommonCodeGenPasses(PM, OptLevel, DisableVerify))      return true;    addCodeEmitter(PM, OptLevel, JCE); @@ -221,13 +226,19 @@ static void printAndVerify(PassManagerBase &PM,  /// emitting to assembly files or machine code output.  ///  bool LLVMTargetMachine::addCommonCodeGenPasses(PassManagerBase &PM, -                                               CodeGenOpt::Level OptLevel) { +                                               CodeGenOpt::Level OptLevel, +                                               bool DisableVerify) {    // Standard LLVM-Level Passes. +  // Before running any passes, run the verifier to determine if the input +  // coming from the front-end and/or optimizer is valid. +  if (!DisableVerify) +    PM.add(createVerifierPass()); +    // Optionally, tun split-GEPs and no-load GVN.    if (EnableSplitGEPGVN) {      PM.add(createGEPSplitterPass()); -    PM.add(createGVNPass(/*NoPRE=*/false, /*NoLoads=*/true)); +    PM.add(createGVNPass(/*NoLoads=*/true));    }    // Run loop strength reduction before anything else. @@ -235,9 +246,6 @@ bool LLVMTargetMachine::addCommonCodeGenPasses(PassManagerBase &PM,      PM.add(createLoopStrengthReducePass(getTargetLowering()));      if (PrintLSR)        PM.add(createPrintFunctionPass("\n\n*** Code after LSR ***\n", &dbgs())); -#ifndef NDEBUG -    PM.add(createVerifierPass()); -#endif    }    // Turn exception handling constructs into something the code generators can @@ -277,6 +285,11 @@ bool LLVMTargetMachine::addCommonCodeGenPasses(PassManagerBase &PM,                                     "*** Final LLVM Code input to ISel ***\n",                                     &dbgs())); +  // All passes which modify the LLVM IR are now complete; run the verifier +  // to ensure that the IR is valid. +  if (!DisableVerify) +    PM.add(createVerifierPass()); +    // Standard Lower-Level Passes.    // Set up a MachineFunction for the rest of CodeGen to work on. @@ -307,6 +320,8 @@ bool LLVMTargetMachine::addCommonCodeGenPasses(PassManagerBase &PM,    if (OptLevel != CodeGenOpt::None) {      PM.add(createOptimizeExtsPass()); +    if (EnableMachineCSE) +      PM.add(createMachineCSEPass());      if (!DisableMachineLICM)        PM.add(createMachineLICMPass());      if (!DisableMachineSink)  | 
