Favour 'integrity' over 'coherence' as a replacement for 'sanity'. (#3619)

This commit is contained in:
Alastair Donaldson 2020-09-10 14:52:21 +01:00 committed by GitHub
parent 8743d385f3
commit ed9863e46e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 15 additions and 17 deletions

View File

@ -61,7 +61,7 @@ void TransformationReplaceCopyMemoryWithLoadStore::Apply(
copy_memory_instruction->opcode() == SpvOpCopyMemory && copy_memory_instruction->opcode() == SpvOpCopyMemory &&
"The required OpCopyMemory instruction must be defined."); "The required OpCopyMemory instruction must be defined.");
// Coherence check: Both operands must be pointers. // Integrity check: Both operands must be pointers.
// Get types of ids used as a source and target of |copy_memory_instruction|. // Get types of ids used as a source and target of |copy_memory_instruction|.
auto target = ir_context->get_def_use_mgr()->GetDef( auto target = ir_context->get_def_use_mgr()->GetDef(
@ -83,7 +83,7 @@ void TransformationReplaceCopyMemoryWithLoadStore::Apply(
source_type_opcode == SpvOpTypePointer && source_type_opcode == SpvOpTypePointer &&
"Operands must be of type OpTypePointer"); "Operands must be of type OpTypePointer");
// Coherence check: |source| and |target| must point to the same type. // Integrity check: |source| and |target| must point to the same type.
uint32_t target_pointee_type = fuzzerutil::GetPointeeTypeIdFromPointerType( uint32_t target_pointee_type = fuzzerutil::GetPointeeTypeIdFromPointerType(
ir_context, target->type_id()); ir_context, target->type_id());
uint32_t source_pointee_type = fuzzerutil::GetPointeeTypeIdFromPointerType( uint32_t source_pointee_type = fuzzerutil::GetPointeeTypeIdFromPointerType(

View File

@ -1063,7 +1063,7 @@ LoopPeelingPass::LoopPeelingInfo::HandleInequality(CmpOperator cmp_op,
} }
uint32_t cast_iteration = 0; uint32_t cast_iteration = 0;
// coherence check: can we fit |iteration| in a uint32_t ? // Integrity check: can we fit |iteration| in a uint32_t ?
if (static_cast<uint64_t>(iteration) < std::numeric_limits<uint32_t>::max()) { if (static_cast<uint64_t>(iteration) < std::numeric_limits<uint32_t>::max()) {
cast_iteration = static_cast<uint32_t>(iteration); cast_iteration = static_cast<uint32_t>(iteration);
} }

View File

@ -579,8 +579,8 @@ bool Optimizer::Run(const uint32_t* original_binary,
#ifndef NDEBUG #ifndef NDEBUG
// We do not keep the result id of DebugScope in struct DebugScope. // We do not keep the result id of DebugScope in struct DebugScope.
// Instead, we assign random ids for them, which results in coherence // Instead, we assign random ids for them, which results in integrity
// check failures. We want to skip the coherence check when the module // check failures. We want to skip the integrity check when the module
// contains DebugScope instructions. // contains DebugScope instructions.
if (status == opt::Pass::Status::SuccessWithoutChange && if (status == opt::Pass::Status::SuccessWithoutChange &&
!context->module()->ContainsDebugScope()) { !context->module()->ContainsDebugScope()) {

View File

@ -91,9 +91,8 @@ void OperandToDominatingIdReductionOpportunityFinder::
// constant. It is thus not relevant to this pass. // constant. It is thus not relevant to this pass.
continue; continue;
} }
// Coherence check: we should not get here if the argument is a assert(!context->get_constant_mgr()->GetConstantFromInst(def) &&
// constant. "We should not get here if the argument is a constant.");
assert(!context->get_constant_mgr()->GetConstantFromInst(def));
if (def->type_id() != candidate_dominator->type_id()) { if (def->type_id() != candidate_dominator->type_id()) {
// The types need to match. // The types need to match.
continue; continue;

View File

@ -92,7 +92,7 @@ std::ostream& operator<<(std::ostream& os, const ParsedInstruction& inst) {
return os; return os;
} }
// Coherence check for the equality operator on ParsedInstruction. // Basic check for the equality operator on ParsedInstruction.
TEST(ParsedInstruction, ZeroInitializedAreEqual) { TEST(ParsedInstruction, ZeroInitializedAreEqual) {
spv_parsed_instruction_t pi = {}; spv_parsed_instruction_t pi = {};
ParsedInstruction a(pi); ParsedInstruction a(pi);

View File

@ -21,8 +21,7 @@ namespace {
TEST(TransformationAddDeadBreakTest, BreaksOutOfSimpleIf) { TEST(TransformationAddDeadBreakTest, BreaksOutOfSimpleIf) {
// For a simple if-then-else, checks that some dead break scenarios are // For a simple if-then-else, checks that some dead break scenarios are
// possible, and coherence-checks that some illegal scenarios are indeed not // possible, and that some invalid scenarios are indeed not allowed.
// allowed.
// The SPIR-V for this test is adapted from the following GLSL, by separating // The SPIR-V for this test is adapted from the following GLSL, by separating
// some assignments into their own basic blocks, and adding constants for true // some assignments into their own basic blocks, and adding constants for true

View File

@ -21,8 +21,8 @@ namespace {
TEST(TransformationAddDeadContinueTest, SimpleExample) { TEST(TransformationAddDeadContinueTest, SimpleExample) {
// For a simple loop, checks that some dead continue scenarios are possible, // For a simple loop, checks that some dead continue scenarios are possible,
// coherence-checks that some illegal scenarios are indeed not allowed, and // checks that some invalid scenarios are indeed not allowed, and then applies
// then applies a transformation. // a transformation.
// The SPIR-V for this test is adapted from the following GLSL, by separating // The SPIR-V for this test is adapted from the following GLSL, by separating
// some assignments into their own basic blocks, and adding constants for true // some assignments into their own basic blocks, and adding constants for true

View File

@ -21,7 +21,7 @@ namespace {
using GetTargetOpcodeTableGetTest = ::testing::TestWithParam<spv_target_env>; using GetTargetOpcodeTableGetTest = ::testing::TestWithParam<spv_target_env>;
using ::testing::ValuesIn; using ::testing::ValuesIn;
TEST_P(GetTargetOpcodeTableGetTest, CoherenceCheck) { TEST_P(GetTargetOpcodeTableGetTest, IntegrityCheck) {
spv_opcode_table table; spv_opcode_table table;
ASSERT_EQ(SPV_SUCCESS, spvOpcodeTableGet(&table, GetParam())); ASSERT_EQ(SPV_SUCCESS, spvOpcodeTableGet(&table, GetParam()));
ASSERT_NE(0u, table->count); ASSERT_NE(0u, table->count);

View File

@ -1323,8 +1323,8 @@ TEST_F(GraphicsRobustAccessTest,
// Split the address calculation across two access chains. Force // Split the address calculation across two access chains. Force
// the transform to walk up the access chains to find the base variable. // the transform to walk up the access chains to find the base variable.
// This time, put the different access chains in different basic blocks. // This time, put the different access chains in different basic blocks.
// This coherence-checks that we keep the instruction-to-block mapping // This is an integrity check to ensure that we keep the instruction-to-block
// consistent. // mapping consistent.
for (auto* ac : AccessChains()) { for (auto* ac : AccessChains()) {
std::ostringstream shaders; std::ostringstream shaders;
shaders << ShaderPreambleAC({"i", "j", "k", "bb1", "bb2", "ssbo_s", shaders << ShaderPreambleAC({"i", "j", "k", "bb1", "bb2", "ssbo_s",

View File

@ -356,7 +356,7 @@ func lex(source string) ([]*Token, []Diagnostic, error) {
lastPos := Position{} lastPos := Position{}
for l.e == nil { for l.e == nil {
// Coherence-check that the parser is making progress // Integrity check that the parser is making progress
if l.pos == lastPos { if l.pos == lastPos {
log.Panicf("Parsing stuck at %v", l.pos) log.Panicf("Parsing stuck at %v", l.pos)
} }