Closed
Bug 423576
Opened 18 years ago
Closed 18 years ago
Treehydra: Expose CFGs
Categories
(Developer Infrastructure :: Source Code Analysis, defect)
Developer Infrastructure
Source Code Analysis
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: dmandelin, Unassigned)
Details
Attachments
(1 file)
|
5.72 KB,
text/plain
|
Details |
| Reporter | ||
Comment 1•18 years ago
|
||
(I hit Enter accidentally before typing the description.)
Please expose CFGs in Treehydra. The CFG data is part of struct Function, which is in treehydra, but the control_flow_graph data shows up as a stub. To make it work, I think you just need to include "basic-block.h" in the headers you use to generate the converters. It looks like this will also require some more GTY patching (also in bitmap.h included from basic-block.h).
When it works, the conversion function for control_flow_graph should have x_entry_block_ptr and x_exit_block_ptr field code. Also the converter for basic_block_def should have edge list vectors.
Comment 2•18 years ago
|
||
Excellent spec, easy to follow, verify. I had to change a whole bunch of things because basic-block.h doesn't get along with jsapi.h(was only a matter of time before something conflicted).
The cfg data structures exposed a couple of bugs in convert_tree.js and omissions, those are fixed now.
Let me know what else is needed.
Status: NEW → ASSIGNED
| Reporter | ||
Comment 3•18 years ago
|
||
It's working pretty well at this point. The attached script will dump CFGs in text form. I've tested it only on small programs and nsBrowserApp.cpp. Also, it punts on decoding the operands for many node types. But, the main point is we can now access the basic blocks, edges, and GIMPLE instructions through Treehydra.
A couple things that could be important going forward:
1. The GCC functions decl_as_string, type_as_string, and loc_as_string (which might be a Dehydra function) are incredibly useful for this stuff, so it would be great to have them exposed through Treehydra. Porting them from C sounds like a pain.
2. Analysis code would do a lot of branching on the operation type. Is there a better way than the following?
let code = TREE_CODE(isn);
if (code == GIMPLE_MODIFY_STMT) {
blah;
} else if (code == RETURN_EXPR) {
blah;
} else ...
For any solution, keep in mind that we will often want to run the same JS for several different tree codes.
Comment 4•18 years ago
|
||
Comment on attachment 311698 [details]
Sample Treehydra script to dump CFGs
>include('/home/dmandelin/gcc-dehydra/dehydra-gcc/treehydra.js');
I guess you noticed that there is no need for absolute names here
>function rectify_function_decl(tree) {
> return {
> name: IDENTIFIER_POINTER(DECL_NAME(tree)),
> resultType: func_return_type_name(tree),
> params: [ {
> name: IDENTIFIER_POINTER(DECL_NAME(o)),
> type: type_string(TREE_TYPE(o)),
> attrs: rectify_attributes(DECL_ATTRIBUTES(o))
> }
> for (o in flatten_chain(DECL_ARGUMENTS(tree))) ],
> };
>}
very nice
>function rectify_statement(stmt) {
> if (TREE_CODE(stmt) == GIMPLE_MODIFY_STMT) {
> return [GIMPLE_MODIFY_STMT, stmt.gstmt.operands];
> } else if (TREE_CODE(stmt) == RETURN_EXPR) {
> return [RETURN_EXPR, stmt.exp.operands];
> }
>}
GENERIC_TREE_OPERAND does what you want
Nice stuff overall. Happy to see this working.
| Reporter | ||
Comment 5•18 years ago
|
||
Well, it works well enough to run the liveness analysis, so I'm gonna call it done. Thanks much!
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Updated•8 years ago
|
Product: Core → Firefox Build System
Updated•4 years ago
|
Product: Firefox Build System → Developer Infrastructure
You need to log in
before you can comment on or make changes to this bug.
Description
•