A method performed by a computing device, the method comprising: receiving a function, the function comprising: function instructions; a plurality of basic blocks (110, 112, 114) comprising respective portions of the function instructions; and at least two execution paths (302, 304) between a first basic block and a second basic block of the plurality of basic blocks; establishing a hash function, the hash function used to compute respective hash values at executed-instruction states of the function instructions; inserting a reset-hash instruction within the first basic block, the reset-hash instruction setting a hash value at an executed-instruction state of the reset-hash instruction to an initial hash-value; selecting a target executed-instruction state within the second basic block; inserting a check-hash instruction at the target executed-instruction state, the check-hash instruction comparing a hash value at the target executed-instruction state to an expected hash-value at the target executed-instruction state; inserting respective hash-input instructions within each of the plurality of basic blocks other than the second basic block, the hash-input instructions setting respective hash input-values to the hash function for computing hash values at executed-instruction states of the hash-input instructions; determining the expected hash-value at the target executed-instruction state and the hash input-values for the hash-input instructions based on the initial hash-value, a canonical value, and the hash function; and forming a compiled function including: the function instructions; the reset-hash instruction with the initial hash-value; the hash-input instructions with the corresponding hash input-values; and the check-hash instruction with the expected hash-value at the target executed-instruction state. receiving a function, the function comprising: function instructions; a plurality of basic blocks (110, 112, 114) comprising respective portions of the function instructions; and at least two execution paths (302, 304) between a first basic block and a second basic block of the plurality of basic blocks; function instructions; a plurality of basic blocks (110, 112, 114) comprising respective portions of the function instructions; and at least two execution paths (302, 304) between a first basic block and a second basic block of the plurality of basic blocks; establishing a hash function, the hash function used to compute respective hash values at executed-instruction states of the function instructions; inserting a reset-hash instruction within the first basic block, the reset-hash instruction setting a hash value at an executed-instruction state of the reset-hash instruction to an initial hash-value; selecting a target executed-instruction state within the second basic block; inserting a check-hash instruction at the target executed-instruction state, the check-hash instruction comparing a hash value at the target executed-instruction state to an expected hash-value at the target executed-instruction state; inserting respective hash-input instructions within each of the plurality of basic blocks other than the second basic block, the hash-input instructions setting respective hash input-values to the hash function for computing hash values at executed-instruction states of the hash-input instructions; determining the expected hash-value at the target executed-instruction state and the hash input-values for the hash-input instructions based on the initial hash-value, a canonical value, and the hash function; and forming a compiled function including: the function instructions; the reset-hash instruction with the initial hash-value; the hash-input instructions with the corresponding hash input-values; and the check-hash instruction with the expected hash-value at the target executed-instruction state. the function instructions; the reset-hash instruction with the initial hash-value; the hash-input instructions with the corresponding hash input-values; and the check-hash instruction with the expected hash-value at the target executed-instruction state.