I'm not sure about one thing: you assign stack slot to each new register you replace the spilled one with. And then you need to allocate physical registers to them. Is it possible to assign physical register to the virtual one which has a stack slot already?
<br><br>
<div><span class="gmail_quote">On 8/21/06, <b class="gmail_sendername">Fernando Magno Quintao Pereira</b> <<a href="mailto:fernando@cs.ucla.edu">fernando@cs.ucla.edu</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><br>> So what addIntervalsToSpills returns are new intervals to allocate with<br>> infinite weights, right?
<br>> And I need not to allocate the old interval. Should hasStackSlot return true<br>> on its register then?<br>><br><br>I am not very sure about addIntervalsToSpill, but, for all the registers<br>created to replace a spilled registers, they must have a stack slot
<br>assigned to them. I am sending you my spilling method, so you can have an<br>example:<br><br>//===--------------------------------------------------------------------------<br>// This method performs register spilling. The parameter indicates a class
<br>of<br>// registers. The spilling algorithm must evict a register from the same<br>class<br>// as the parameter. I am using the VirtRegMap class to place loads and<br>stores.<br>//===--------------------------------------------------------------------------
<br>void RegAllocChordal_Fer::spill(<br> unsigned v_reg,<br> KillingSites_Fer & ks,<br> const MachineBasicBlock & mbb<br>) {<br> // First, find a place to store this register. Of course, this will be<br>done
<br> // by the implementation of vrm. We just have to ask it.<br> int slot = vrm->assignVirt2StackSlot(v_reg);<br> unsigned p_reg = this->reg_mapping->get_physical_location(v_reg);<br><br> // Now, it is necessary to break the live range of the spilled
<br>register.<br> // This is done by creating new virtual registers, and substituting<br>the<br> // spilled register by the new registers.<br> MachineInstr * last_seen;<br> std::vector< MachineInstr * > & use_sites =
<br><br>this->def_use_sites->get_use_sites(v_reg);<br> for(unsigned u = 0; u < use_sites.size(); u++) {<br> MachineInstr * mi = use_sites[u];<br> if(mi == last_seen) {<br> continue; // this happens when the same virtual is used
<br>multiple<br> // times in the same instruction.<br> }<br> unsigned new_reg = create_new_virtual_register(v_reg);<br> if(mi->getParent()->getNumber() ==<br>ks.get_basic_block()->getNumber()) {
<br> ks.replace_used_reg(mi, new_reg, v_reg);<br> }<br> this->vrm->grow();<br> this->reg_mapping->grow();<br> this->vrm->assignVirt2StackSlot(new_reg, slot);<br> for(unsigned t = 0; t < mi->getNumOperands(); t++) {
<br> MachineOperand & mo_aux = mi->getOperand(t);<br> if(mo_aux.isRegister() && mo_aux.getReg() && mo_aux.isUse()) {<br> if(mo_aux.getReg() == v_reg) {<br> mo_aux.setReg(new_reg);
<br> this->reg_mapping->set_color_spilled_register<br> (new_reg, p_reg);<br> }<br> }<br> }<br> last_seen = mi;
<br> }<br><br> // this method will clean the machine register, e.g. p_reg, that is<br>been<br> // currently used to hold the color of v_reg.<br> this->reg_mapping->liberate_color(p_reg);<br><br> clean_live_range(ks, v_reg, mbb);
<br>}<br>_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a>
<br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></blockquote></div><br><br clear="all"><br>-- <br>Nae king! Nae quin! Nae laird! Nae master! We willnae be fooled again!