Add an enable_verifier setting.

This is off by default, but enabled by the parser when reading a textual
IL file. Test files can still override the default to turn off
verification.

The setting enables IL verifier passes at critical points of the
compilation pipeline.
This commit is contained in:
Jakob Stoklund Olesen
2017-04-21 09:49:03 -07:00
parent 3005f903f7
commit 866efd91b7
3 changed files with 21 additions and 2 deletions

View File

@@ -17,7 +17,7 @@ use cretonne::ir::immediates::{Imm64, Offset32, Uoffset32, Ieee32, Ieee64};
use cretonne::ir::entities::AnyEntity;
use cretonne::ir::instructions::{InstructionFormat, InstructionData, VariableArgs};
use cretonne::isa::{self, TargetIsa, Encoding};
use cretonne::settings;
use cretonne::settings::{self, Configurable};
use testfile::{TestFile, Details, Comment};
use error::{Location, Error, Result};
use lexer::{self, Lexer, Token};
@@ -577,6 +577,13 @@ impl<'a> Parser<'a> {
let mut isas = Vec::new();
let mut flag_builder = settings::builder();
// Change the default for `enable_verifier` to `true`. It defaults to `false` because it
// would slow down normal compilation, but when we're reading IL from a text file we're
// either testing or debugging Cretonne, and verification makes sense.
flag_builder
.set_bool("enable_verifier", true)
.expect("Missing enable_verifier setting");
while let Some(Token::Identifier(command)) = self.token() {
match command {
"set" => {
@@ -1849,7 +1856,10 @@ mod tests {
assert_eq!(tf.commands[0].command, "cfg");
assert_eq!(tf.commands[1].command, "verify");
match tf.isa_spec {
IsaSpec::None(s) => assert!(!s.enable_float()),
IsaSpec::None(s) => {
assert!(s.enable_verifier());
assert!(!s.enable_float());
}
_ => panic!("unexpected ISAs"),
}
assert_eq!(tf.preamble_comments.len(), 2);