How does BlockAddress map to MachineBasicBlock?


If we use BlockAddress of the IR ,

there will be corresponding label in the Machine IR.

So that we can get the address of BasicBlcok from this label.

Now, I use BlockAddress to get the address of CallInst in IR level.

I want to adjust the label in MIR to get the address of exactly call instruction.

Because the CallInst is often lowered to more than one MIR/asm.

like maintaining stack pointer, argument preparing and the call instruction.

So, my question is

How can I change the mapping between BlockAddress and label in MIR?

Can I split a MBB and let the Blockaddress map to the new MBB?

Or how to change the location of label in MIR ?

I just want to move the label back like one or two instruction to the call instruction.

Thank you

In general you can’t do that via block address. However, you should be able to attach a symbol to the call instruction (MachineInstr) which would serve as a label identifying the instruction. Look for “MachineInstr::setPreInstrSymbol", although the comment in the header file says that it’s not completely implemented yet.