[cfe-dev] Clang Control Flow Graph?

Sung-Yee Guo masoug at gmail.com
Wed Aug 7 10:05:27 PDT 2013


Good point. But the code I'm parsing never have goto statements.

I'm not actually trying to perform an exhaustive search through the CFG, I'm
just starting at some block and walking up through the predecessors until I
hit the ENTRY block. With the depth-first iterator, it seems to me that I
should first assign special numbers to each block that follows the
depth-first order and then have the walker walk up the CFG and avoid
predecessors whose depth-first number is less than the current block's
depth-first number (seems a bit inefficient, unless I can reassign block ids
which I'm guessing is not safe?). Do you have any suggestions for
alternatives?

From:  Jordan Rose <jordan_rose at apple.com>
Date:  Wednesday, August 7, 2013 9:42 AM
To:  Sung-Yee Guo <masoug at gmail.com>
Cc:  <cfe-dev at cs.uiuc.edu>, Developers <cfe-dev at cs.uiuc.edu>
Subject:  Re: [cfe-dev] Clang Control Flow Graph?

What about goto? I don't think you're going to be able to get out of a
proper visited set.


On Aug 7, 2013, at 9:36 , Sung-Yee Guo <masoug at gmail.com> wrote:

> Thanks for the reply! I'll just check the block terminator type then.
> 
> -Masoug
> 
> 
> From:  Jordan Rose <jordan_rose at apple.com>
> Date:  Wednesday, August 7, 2013 9:30 AM
> To:  Sung-Yee Guo <masoug at gmail.com>
> Cc:  <cfe-dev at cs.uiuc.edu>, Developers <cfe-dev at cs.uiuc.edu>
> Subject:  Re: [cfe-dev] Clang Control Flow Graph?
> 
> Hi, Masoug. No, I don't think it's safe to make that assumption, even if it's
> true today. You'll have to use a visited set; llvm::SmallPtrSet should be able
> to handle it quite well.
> 
> Best,
> Jordan
> 
> 
> On Aug 6, 2013, at 18:37 , Sung-Yee Guo <masoug at gmail.com> wrote:
> 
>> Hi,
>> Just a quick question: Are the CFGBlock IDs strictly assigned in the
>> depth-first order? I was trying to traverse the CFG but terminators like for
>> loops "trap" me into an infinite loop; the successors have a path back to the
>> predecessor of some blocks. My thinking was that if the block ids were
>> assigned in a specific order, I may be able to use them as a way to avoid
>> running into infinite loops (and stack overflows).
>> 
>> Thanks!
>> -Masoug
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
> 



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130807/e9f2cf77/attachment.html>


More information about the cfe-dev mailing list