<div dir="ltr">If you are working at the MachineInstr level, try using setPostInstrSymbol to place your own label after the call in question. That is the reliable way of getting the address of a specific instruction.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Mar 13, 2020 at 8:47 PM PenYiWang via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">---------- Forwarded message ---------<br>寄件者: <strong class="gmail_sendername" dir="auto">PenYiWang</strong> <span dir="auto"><<a href="mailto:s89162504@gmail.com" target="_blank">s89162504@gmail.com</a>></span><br>Date: 2020年3月14日 週六 11:24<br>Subject: Re: [llvm-dev] Why MachineBasicBlcok doesn't have transferPredecessors() ?<br>To: Nicolai Hähnle <<a href="mailto:nhaehnle@gmail.com" target="_blank">nhaehnle@gmail.com</a>><br></div><br><br><div dir="auto">for example<div dir="auto"> </div><div dir="auto">in llvm ir level, I use BlockAddress to get the address of a BasicBlock, which is started with a Call Inst ir.</div><div dir="auto"><br></div><div dir="auto">/*</div><div dir="auto">I want to get the address of exactly the call instruction in asm level.<br></div><div dir="auto">*/</div><div dir="auto"><br></div><div dir="auto">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.</div><div dir="auto"><br></div><div dir="auto">that' why i want to spilt the MachineBasicBlock </div><div dir="auto"><br></div><div dir="auto">and move out the ”sub rsp“ or ”mov rdi“ to the new mbb before the original mbb, </div><div dir="auto"><br></div><div dir="auto">so that i can keep the call instruction as the first instruction of the MachineBasicBlock.</div><div dir="auto"><br></div><div dir="auto">so i need to maintain the predecessor of the new mbb, </div><div dir="auto">(because i insert a new mbb “before” the original mbb)</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Nicolai Hähnle <<a href="mailto:nhaehnle@gmail.com" rel="noreferrer noreferrer noreferrer" target="_blank">nhaehnle@gmail.com</a>> 於 2020年3月14日 週六 09:18 寫道:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Fri, Mar 13, 2020 at 5:09 PM PenYiWang <<a href="mailto:s89162504@gmail.com" rel="noreferrer noreferrer noreferrer noreferrer" target="_blank">s89162504@gmail.com</a>> wrote:<br>
> for example<br>
><br>
> I want to insert a new machine bb “before” a specific machine bb.<br>
><br>
> or split a mbb and keep the later one as the original one.<br>
> (to keep the label/Blackadder's correct<br>
> t)<br>
<br>
Can you explain why that would make a difference? Basic block labels<br>
ought to be irrelevant for codegen.<br>
<br>
<br>
> (or keep other property of mbb)<br>
<br>
What property?<br>
<br>
Cheers,<br>
Nicolai<br>
<br>
<br>
><br>
> so I need to transfer the original mbb's predecessor to the new mbb.<br>
><br>
><br>
><br>
><br>
><br>
> Nicolai Hähnle <<a href="mailto:nhaehnle@gmail.com" rel="noreferrer noreferrer noreferrer noreferrer" target="_blank">nhaehnle@gmail.com</a>> 於 2020年3月13日 週五 23:57 寫道:<br>
>><br>
>> On Fri, Mar 13, 2020 at 12:22 PM PenYiWang via llvm-dev<br>
>> <<a href="mailto:llvm-dev@lists.llvm.org" rel="noreferrer noreferrer noreferrer noreferrer" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
>> > I found that there is transferSuccessors() in MachineBasicBlcok<br>
>> ><br>
>> > So that when manipulating MachineBasicBlock,<br>
>> > we can use transferSuccessors to update the CFG easily.<br>
>> ><br>
>> > Why there is not transferPredecessors in MachineBasicBlcok ?<br>
>><br>
>> What would you want to use it for? If it's for splitting a block: the<br>
>> common pattern for splitting seems to be to create a new block that<br>
>> will be the successor of the old one rather than the other way around.<br>
>> One good reason for this is that doing it this way only requires<br>
>> fixing up (target-independent) phi instructions, while doing it the<br>
>> other way around would require fixing up the (target-specific!) branch<br>
>> instructions.<br>
>><br>
>> Cheers,<br>
>> Nicolai<br>
>><br>
>><br>
>> --<br>
>> Lerne, wie die Welt wirklich ist,<br>
>> aber vergiss niemals, wie sie sein sollte.<br>
<br>
<br>
<br>
-- <br>
Lerne, wie die Welt wirklich ist,<br>
aber vergiss niemals, wie sie sein sollte.<br>
</blockquote></div>
</div></div></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>