Hi, I would like to know what register scavenging is, but reading RegisterScavenging.h [1] and googling don't help too much. Could someone explain it a little bit (what it is and when we need it), or point me to some nice link, I will be very appreciated. :-) [1] http://llvm.org/docs/doxygen/html/RegisterScavenging_8h_source.html Regards, chenwj -- Wei-Ren Chen (陳韋任) Homepage: https://people.cs.nctu.edu.tw/~chenwj
Hi Chen, On 2 April 2017 at 07:21, 陳韋任 via llvm-dev <llvm-dev at lists.llvm.org> wrote:> I would like to know what register scavenging is, but reading > RegisterScavenging.h [1] and googling don't help too much. Could someone explain it a little > bit (what it is and when we need it), or point me to some nice link, I will be very appreciated. :-)It's a helper for passes that run after register allocation but still need a new register they can use without breaking anything. It looks around nearby instructions[*] to see if there's anything it can prove is unused at the moment, and as a last ditch effort can spill registers to the stack. It's not commonly used (better to arrange to have a register allocated for you if possible), but occasionally helpful in things like frame lowering. Cheers. Tim. [*] This is where the "scavenger" name comes from: hunting around for discarded registers sort of like the animals.
> > It's a helper for passes that run after register allocation but still > need a new register they can use without breaking anything. It looks > around nearby instructions[*] to see if there's anything it can prove > is unused at the moment, and as a last ditch effort can spill > registers to the stack. >I am reading TriCore document [1]. It mention `eliminateFrameIndex`, which is a pass after register allocation, translates virtual stack slot reference to a register-offset pair. If the offset is too large, additional instructions are needed to compute the effective address, which need more register after the register allocation. Now comes the register scavenging. Now I understand what it said after your help. One last point, I am not native English speaker. By "as a last ditch effort can spill registers to the stack.", you mean if register scavenging cannot save us, then we have to do the spilling? Thanks. [1] https://wwwcip.informatik.uni-erlangen.de/~sicherha/foo/tricore-llvm.pdf Regards, chenwj -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170403/b8ccc574/attachment.html>