[llvm-dev] What is register scavenging?

502 views
Skip to first unread message

陳韋任 via llvm-dev

unread,
Apr 2, 2017, 10:21:08 AM4/2/17
to LLVM Developers Mailing List
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
_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

Tim Northover via llvm-dev

unread,
Apr 2, 2017, 11:12:34 AM4/2/17
to 陳韋任, LLVM Developers Mailing List
Hi Chen,

On 2 April 2017 at 07:21, 陳韋任 via llvm-dev <llvm...@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.

陳韋任 via llvm-dev

unread,
Apr 2, 2017, 6:56:57 PM4/2/17
to Tim Northover, LLVM Developers Mailing List
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.


Regards,
chenwj
Reply all
Reply to author
Forward
0 new messages