[LLVMdev] How to update LiveInterval information of newly inserted machine basic block

Haishan hndxvon at 163.com
Fri Jan 3 04:58:33 PST 2014


At 2014-01-01 04:36:21,"Andrew Trick" <atrick at apple.com> wrote:


On Dec 31, 2013, at 3:52 AM, Haishan <hndxvon at 163.com> wrote:


Hi,
  I insert a new machine basic block(MBB) before Greedy Register Allocation, after Simple Register Coalescing. But I encounter a fatal 
error "regalloc = ... not currently supported with -O0". I use command line with opt level O2, not O0.
The probable reason of this error is that no LiveInterval information for newly MBB which is used by Register Allocation.
And, LiveIntervals depend on LiveVariables which require the machine function to be in SSA form.
However, in this case, the modified machine function(including newly inserted MBB) is not SSA form any more.
So, how to update LiveInterval information of newly MBB?
Could someone help me with that?
Thank you very much in advance.
-Haishan


Yes, I think error that means LiveIntervals have been invalidated. It is supposed to be user-friendly but should probably be changed to be more specific.


If you schedule a new pass between coalescing and regalloc, it needs to preserve LiveIntervals analysis. There are utilities to recompute live intervals for individual virtual registers. See LiveIntervals::computeVirtRegs. LiveVariables is not actually needed to update live intervals. It is only added as a requirement to make sure it runs before the 2-address pass.


-Andy


  Thank you for your reply.
  I do it as you tell me, and you are right.
  My update steps are shown following:
  LiveIntervals *LIS = &getAnalysis<LiveIntervals>();
    1. LIS->insertMBBInMaps(NewMBB)
    2. LIS->InsertMachineInstrRangeInMaps(NewMBB->begin(), NewMBB->end())
    3. Due to some machine instructions of NewMBB copy from OldMBB, I have to removeInterval firstly. Then I use LIS->createAndComputeVirtRegInterval() to update LiveInterval info of NewMBB.
    4. Then I want to delete OldMBB in the current MachineFuncion. At the same time, delete LiveIntervals info of OldMBB. So, firstly, Use RemoveMachineInstrFromMaps() to erase SlotIndexes info of OldMBB. And, delete OldMBB from current CFG. Lastly, remove all registers' interval, create and recompute virtual register interval info.
  However, I get an unreachable error "Use not jointly dominated by defs" in LiveRangeCalc.cpp:188.
So, comparing with Step3, Step4 generates an unreachable error, Why?
  Valid information of OldMBB is deleted when updating CFG? Is there something wrong with my updating steps?
  Thank you very much again.
  -Haishan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140103/8f91a78c/attachment.html>


More information about the llvm-dev mailing list