MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / verify_inst_arg

Method verify_inst_arg

cranelift/codegen/src/verifier/mod.rs:1004–1093  ·  view source on GitHub ↗
(
        &self,
        loc_inst: Inst,
        v: Value,
        errors: &mut VerifierErrors,
    )

Source from the content-addressed store, hash-verified

1002 }
1003
1004 fn verify_inst_arg(
1005 &self,
1006 loc_inst: Inst,
1007 v: Value,
1008 errors: &mut VerifierErrors,
1009 ) -> VerifierStepResult {
1010 self.verify_value(loc_inst, v, errors)?;
1011
1012 let dfg = &self.func.dfg;
1013 let loc_block = self
1014 .func
1015 .layout
1016 .inst_block(loc_inst)
1017 .expect("Instruction not in layout.");
1018 let is_reachable = self.expected_domtree.is_reachable(loc_block);
1019
1020 // SSA form
1021 match dfg.value_def(v) {
1022 ValueDef::Result(def_inst, _) => {
1023 // Value is defined by an instruction that exists.
1024 if !dfg.inst_is_valid(def_inst) {
1025 return errors.fatal((
1026 loc_inst,
1027 self.context(loc_inst),
1028 format!("{v} is defined by invalid instruction {def_inst}"),
1029 ));
1030 }
1031 // Defining instruction is inserted in a block.
1032 if self.func.layout.inst_block(def_inst) == None {
1033 return errors.fatal((
1034 loc_inst,
1035 self.context(loc_inst),
1036 format!("{v} is defined by {def_inst} which has no block"),
1037 ));
1038 }
1039 // Defining instruction dominates the instruction that uses the value.
1040 if is_reachable {
1041 if !self
1042 .expected_domtree
1043 .dominates(def_inst, loc_inst, &self.func.layout)
1044 {
1045 return errors.fatal((
1046 loc_inst,
1047 self.context(loc_inst),
1048 format!("uses value {v} from non-dominating {def_inst}"),
1049 ));
1050 }
1051 if def_inst == loc_inst {
1052 return errors.fatal((
1053 loc_inst,
1054 self.context(loc_inst),
1055 format!("uses value {v} from itself"),
1056 ));
1057 }
1058 }
1059 }
1060 ValueDef::Param(block, _) => {
1061 // Value is defined by an existing block.

Callers 1

Calls 13

OkFunction · 0.85
verify_valueMethod · 0.80
inst_blockMethod · 0.80
value_defMethod · 0.80
inst_is_validMethod · 0.80
fatalMethod · 0.80
block_is_validMethod · 0.80
is_block_insertedMethod · 0.80
expectMethod · 0.45
is_reachableMethod · 0.45
contextMethod · 0.45
dominatesMethod · 0.45

Tested by

no test coverage detected