[MachineLICM] how to add target-special constraints


I am facing a problem that MachineLICM is hoisting some MachineInstrs that are special for my target. I do not want to disable the optimization so I am looking for some solutions to avoid such hoisting. I have not seen anyone create subclass for MachineLICMBase either.

Looking at the implementation in MachineLICMBase::ProcessMI(), I could not find a place to add target specific constraints (for example, defines to certain registers cannot be hoisted). There is no target-specific callbacks I can overwrite.

One possible fix I can think of is to initialize PhysRegClobbers with the special registers. However, that will require a lot of changes to the common codebase, for example, I might need to add some helper functions in TargetRegisterInfo. I am not sure if that is a good idea.

Any suggestions are highly appreciated.

Many thanks,