[llvm-dev] Spare Register at one Machine Instruction

Matthias Braun via llvm-dev llvm-dev at lists.llvm.org
Mon Jan 23 11:49:20 PST 2017


Sounds like Hu found a solution, so this is just for the record:

> On Jan 21, 2017, at 2:23 AM, Nemanja Ivanovic <nemanja.i.ibm at gmail.com> wrote:
> 
> I just realized that I forgot to mention where you can get the info about a physical register unused in the function (if that's what you're after):
> MachineRegisterInfo::isConstantPhysReg()
isConstantPhysReg() is not really a test for checking whether a register is completely unused in a function. That is done with MachineRegisterInfo::isPhysRegUsed().

> 
> On Sat, Jan 21, 2017 at 11:17 AM, Nemanja Ivanovic <nemanja.i.ibm at gmail.com <mailto:nemanja.i.ibm at gmail.com>> wrote:
> I'm not sure exactly what you're after.
> I was under the impression that you want to know which register is live at a specific point (an instruction). If that's the case, how do one of the two suggested solutions not suffice?
> If a register is live-in to a block and not killed before your instruction or it has a def and no kill within the block, it is live. Otherwise it is dead and available. Isn't it?
> Or are you interested in whether a physical register is unused in the entire function?
> 
> On Sat, Jan 21, 2017 at 10:21 AM, Hong Hu <huhong789 at gmail.com <mailto:huhong789 at gmail.com>> wrote:
> Hi Nemanja and Matthias,
> 
> Thanks for the reply. 
> 
> I checked both Register Scavenger and LivePhysReg. It seems that both work on the BasicBlock level, right? 
> 
> Is it possible to perform such analysis in a whole function? For example, considering the calling convention (where the rsi, rdi will be in use from the beginning) and the return convention (where rax will be in use in the last bb).
> 
> Regards,
> Hu Hong
> 
> On 20 January 2017 at 03:55, Matthias Braun <mbraun at apple.com <mailto:mbraun at apple.com>> wrote:
> There is also the LivePhysReg facility that I would recomment if you just want to query for a free register and do not need the full feature set of the RegisterScavenger.
> 
> - Matthias
> 
>> On Jan 19, 2017, at 5:50 AM, Nemanja Ivanovic via llvm-dev <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>> wrote:
>> 
>> I believe what you're after is the register scavenger.
>> It's in: include/llvm/CodeGen/RegisterScavenging.h
>> Implementation: lib/CodeGen/RegisterScavenging.cpp
>> 
>> On Thu, Jan 19, 2017 at 1:36 PM, Hong Hu via llvm-dev <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>> wrote:
>> Hi All,
>> 
>> Given a machine instruction, is it possible to tell which register(s) is still not in use? 
>> 
>> For example, given one instruction A, if the one follows it (say B) defines register rax, then I can tell rax should spare at instruction A. 
>> 
>> The purpose is to use the spare register to replace registers used by A, for instrumentation purpose.
>> 
>> Regards,
>> Hu Hong
>> 
>> _______________________________________________
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev <http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev>
>> 
>> 
>> _______________________________________________
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev <http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev>
> 
> 
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170123/821d785d/attachment.html>


More information about the llvm-dev mailing list