[llvm-commits] [PATCH] SuccIterator on bbs without terminator insts

Tobias Grosser grosser at fim.uni-passau.de
Mon Jul 4 16:15:55 PDT 2011


On 07/04/2011 04:48 PM, Chris Lattner wrote:
> On Jul 3, 2011, at 10:26 PM, Tobias Grosser wrote:
>>> Intuitively no, because all basic blocks are required to have
>>> terminators. But I suspect you ran into this for a reason, and tools
>>> like succ_begin/end() may not be able to assume that the CFG is valid at
>>> any point in time because the IR is being modified. Could you explain
>>> more about what you were doing which triggered this?
>>
>> It's pretty easy.
>>
>> In Polly we modify the CFG by adding some additional basic blocks
>> (actually a branch that contains an optimized code path). Once in a
>> while (because of a bug in Polly or somewhere in LLVM) I have a failing
>> test case. My first step to investigate a bug is to put a breakpoint at
>> the place in the code where I suspect the bug (or an assert triggered).
>> My next step is to call F->viewCFG() to see the current state of the
>> CFG. Unfortunately this almost never works, as the CFG is at this point
>> not yet fully constructed and consequently the above assert triggers.
>>
>> In general I believe for debugging it would be very helpful if
>> F->viewCFG() would already work during the construction of the CFG.
>
> I agree with Nick that this is really counterintuitive, but your logic makes sense to me.  Please commit with a comment explaining that getTerminator() is allowed to return null for malformed CFGs.

Committed in 134398.

Cheers
Tobi



More information about the llvm-commits mailing list