(
&self,
loc_inst: Inst,
v: Value,
errors: &mut VerifierErrors,
)
| 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. |
no test coverage detected