Code to validate the IR in a Context.
Context
During creation, deserialization and optimization the IR should be verified to be in a consistent valid state, using the functions in this module.