[LLVMdev] Possible LiveInterval Bug

David Greene dag at cray.com
Wed Jan 30 13:21:58 PST 2008


On Wednesday 30 January 2008 15:06, Evan Cheng wrote:
> Hrm, I see a bug here. Let's say the liverange in question is [13,20)
> and the interval it's being merged to is something like this: [1, 4),
> [10, 15)
>
>      IP = std::upper_bound(IP, end(), Start);
>      if (IP != begin() && IP[-1].end > Start) {
>         if (IP->valno != LHSValNo) {
>           ReplacedValNos.push_back(IP->valno);
>           IP->valno = LHSValNo; // Update val#.
>         }
>
> IP is end() and we would be pushing junk into ReplacedValNos. Is this
> what you saw?

Yep, exactly.

> I wonder if the fix should be changing the inner if to:
> if (IP[-1].valno != LHSValNo) {
>    ReplacedValNos.push_back(IP[-1].valno);
>    IP[-1].valno = LHSValNo;
> }

I was thinking along the same lines.  But does this work for the cases where
IP is _not_ end()?  Is it true that we always want to look one back from IP?

                                             -Dave



More information about the llvm-dev mailing list