Adding a prologue to BB

Hello,
In the backend I’m working on there is a value to handle each BB separately,
Therefore I’d like to create a prologue for each BB and I was wondering what would be the correct way to do such a thing (I know there is a emitPrologue hook, but it’s per function).
The way I’ve figured out so far are:

  1. Making the EntryToken SDNode illegal and use the LowerOperation hook to add things after that node without removing it.
  2. Writing a custom pass that will iterate through all the BB’s and add a prologue to them.

I was wondering if there is any other way I’ve missed, and would like to hear your opinion on the 2 ways I’ve found, thank you very much!