Figuring out whether a given override should apply to a given define
or declare in an LLVM module is not as easy as seeing if their names
match. For some C++ overrides, for example, checking if the override
should apply requires demangling the function name, which is an
expensive proposition.
For this reason, override matching happens in two "phases" in
Crucible-LLVM: first, there is an initial, fast, string-based
TemplateMatcher that is used to filter out overrides that definitely
don't apply. Then, if any remain, there is a second phase that
inspects the declaration in more detail to see if the override matches.
Previously, this second phase consisted of a RegOverrideM (i.e.,
OverrideSim) action that would actually perform the registration.
This is unnecessarily flexible. The second phase is only really supposed
to perform the inspection of the declaration, construct an override, and
register it. Therefore, it's been replaced by a pure function that
returns a Maybe (SomeLLVMOverride ...), which can then be registered
by client code, if desired.
This more restrictive type should help clarify the intent of the
override matching code, and reduce the potential for superfluous use
of OverrideSim effects.
Figuring out whether a given override should apply to a given
define
ordeclare
in an LLVM module is not as easy as seeing if their names match. For some C++ overrides, for example, checking if the override should apply requires demangling the function name, which is an expensive proposition.For this reason, override matching happens in two "phases" in Crucible-LLVM: first, there is an initial, fast, string-based
TemplateMatcher
that is used to filter out overrides that definitely don't apply. Then, if any remain, there is a second phase that inspects the declaration in more detail to see if the override matches.Previously, this second phase consisted of a
RegOverrideM
(i.e.,OverrideSim
) action that would actually perform the registration. This is unnecessarily flexible. The second phase is only really supposed to perform the inspection of the declaration, construct an override, and register it. Therefore, it's been replaced by a pure function that returns aMaybe (SomeLLVMOverride ...)
, which can then be registered by client code, if desired.This more restrictive type should help clarify the intent of the override matching code, and reduce the potential for superfluous use of
OverrideSim
effects.