[llvm-dev] Fwd: Why MachineBasicBlcok doesn't have transferPredecessors() ?

PenYiWang via llvm-dev llvm-dev at lists.llvm.org
Fri Mar 13 20:47:24 PDT 2020


---------- Forwarded message ---------
寄件者: PenYiWang <s89162504 at gmail.com>
Date: 2020年3月14日 週六 11:24
Subject: Re: [llvm-dev] Why MachineBasicBlcok doesn't have
transferPredecessors() ?
To: Nicolai Hähnle <nhaehnle at gmail.com>


for example

in llvm ir level, I use BlockAddress to get the address of a BasicBlock,
which is started with a Call Inst ir.

/*
I want to get the address of  exactly the call instruction in asm level.
*/

but in llvm backend, llvm will insert some instruction before the call,
like “sub rsp” or “mov rdi” , so the BlockAddress would get the address in
front of the call instruction.

that' why i want to spilt the MachineBasicBlock

and move out the ”sub rsp“ or ”mov rdi“ to the new mbb before the original
mbb,

so that i can keep the call instruction as the first instruction of the
MachineBasicBlock.

so i need to maintain the predecessor of the new mbb,
(because i insert a new mbb “before” the original mbb)

Nicolai Hähnle <nhaehnle at gmail.com> 於 2020年3月14日 週六 09:18 寫道:

> On Fri, Mar 13, 2020 at 5:09 PM PenYiWang <s89162504 at gmail.com> wrote:
> > for example
> >
> > I want to insert a new machine bb “before” a specific machine bb.
> >
> > or split a mbb and keep the later one as the original one.
> > (to keep the label/Blackadder's correct
> > t)
>
> Can you explain why that would make a difference? Basic block labels
> ought to be irrelevant for codegen.
>
>
> > (or keep other property of mbb)
>
> What property?
>
> Cheers,
> Nicolai
>
>
> >
> > so I need to transfer the original mbb's predecessor to the new mbb.
> >
> >
> >
> >
> >
> > Nicolai Hähnle <nhaehnle at gmail.com> 於 2020年3月13日 週五 23:57 寫道:
> >>
> >> On Fri, Mar 13, 2020 at 12:22 PM PenYiWang via llvm-dev
> >> <llvm-dev at lists.llvm.org> wrote:
> >> > I found that there is transferSuccessors() in MachineBasicBlcok
> >> >
> >> > So that when manipulating MachineBasicBlock,
> >> > we can use transferSuccessors to update the CFG easily.
> >> >
> >> > Why there is not transferPredecessors in  MachineBasicBlcok ?
> >>
> >> What would you want to use it for? If it's for splitting a block: the
> >> common pattern for splitting seems to be to create a new block that
> >> will be the successor of the old one rather than the other way around.
> >> One good reason for this is that doing it this way only requires
> >> fixing up (target-independent) phi instructions, while doing it the
> >> other way around would require fixing up the (target-specific!) branch
> >> instructions.
> >>
> >> Cheers,
> >> Nicolai
> >>
> >>
> >> --
> >> Lerne, wie die Welt wirklich ist,
> >> aber vergiss niemals, wie sie sein sollte.
>
>
>
> --
> Lerne, wie die Welt wirklich ist,
> aber vergiss niemals, wie sie sein sollte.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200314/c4f8cd66/attachment.html>


More information about the llvm-dev mailing list