|
@@ -115,9 +115,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 +194,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,9 +223,15 @@ 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());
|
|
@@ -235,9 +243,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 +282,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.
|