-fdump-tree-all documentation.

DCH david@carter-hitchin.clara.co.uk
Tue Mar 13 20:44:00 GMT 2007


Hi Andrew et alumni,

At 08:57 13/03/2007, Andrew Haley wrote:
>DCH writes:
>
>  > Forgive me if I've missed something obvious, but does anyone
>  > know if the output from -fdump-tree-all is documented somewhere?
>
>It's C, more or less, except for a few additions such as Phi nodes.

I guess that means no :-)  Looks nothing like C to me, but there again
I'm used to looking a normal type C, not some kind of parsed C.

>Which part are you having difficulty with?

Well, most of it really.  Basically someone posted this to ACCU-general
a while ago:

====================================================
struct no_default_ctor {
         no_default_ctor(int i) : m_i(i) { };
         ~no_default_ctor() { };
       private:
         no_default_ctor();
         const int m_i;
     };

//  Why is `no_default_ctor(Anint)' below a syntax error?

     const int Anint = 3;
     int foo() {
         no_default_ctor name(Anint);    // This works.
         no_default_ctor(Anint);         // This gives me a syntax error.
         no_default_ctor(3);             // But this does not.
         (no_default_ctor)(Anint);       // And neither does this.
     }
====================================================

It provoked some discussion, the outcome of that was rather 
unclear.  I thought
at least I could pass it into GCC to see how no_default_ctor(Anint) is parsed
and got the following output.  I think I decided at the time that it was being
interpreted as a function-style cast, but then I wasn't sure, and now I can't
even see that for some reason.  There was some discussion if it was a cast
or a declaration.  There are a couple of references in the output below to
line 13 but I don't know the syntax here to unwind it.

;; Function int foo() (_Z3foov)
;; enabled by -fdump-tree-original

@1      function_decl    name: @2       mngl: @3       type: @4
                          srcp: ctors_orig.cpp:12       extern
                          body: @5
@2      identifier_node  strg: foo      lngt: 3
@3      identifier_node  strg: _Z3foov  lngt: 7
@4      function_type    size: @6       algn: 64       retn: @7
                          prms: @8
@5      compound_stmt    line: 17       body: @9
@6      integer_cst      type: @10      low : 64
@7      integer_type     name: @11      size: @12      algn: 32
                          prec: 32       min : @13      max : @14
@8      tree_list        valu: @15
@9      scope_stmt       line: 12       begn           clnp
                          next: @16
@10     integer_type     name: @17      size: @6       algn: 64
                          prec: 36       unsigned       min : @18
                          max : @19
@11     type_decl        name: @20      type: @7       srcp: <internal>:0
                          artificial
@12     integer_cst      type: @10      low : 32
@13     integer_cst      type: @7       high: -1       low : -2147483648
@14     integer_cst      type: @7       low : 2147483647
@15     void_type        name: @21      algn: 8
@16     compound_stmt    line: 12       body: @22      next: @23
@17     identifier_node  strg: bit_size_type           lngt: 13
@18     integer_cst      type: @10      low : 0
@19     integer_cst      type: @10      low : -1
@20     identifier_node  strg: int      lngt: 3
@21     type_decl        name: @24      type: @15      srcp: <internal>:0
                          artificial
@22     scope_stmt       line: 12       begn           clnp
                          next: @25
@23     scope_stmt       line: 17       end            clnp
@24     identifier_node  strg: void     lngt: 4
@25     decl_stmt        line: 13       decl: @26      next: @27
@26     var_decl         name: @28      type: @29      scpe: @1
                          srcp: ctors_orig.cpp:13       size: @30
                          algn: 32       used: 1
@27     expr_stmt        line: 13       expr: @31      next: @32
@28     identifier_node  strg: name     lngt: 4
@29     record_type      name: @33      size: @30      algn: 32
                          struct         flds: @34      fncs: @35
                          binf: @36
@30     integer_cst      type: @10      low : 32
@31     stmt_expr        type: @15      stmt: @37
@32     cleanup_stmt     line: 13       decl: @26      expr: @38
                          next: @39
@33     type_decl        name: @40      type: @29      srcp: 
ctors_orig.cpp:1
                          artificial
@34     field_decl       name: @41      type: @42      scpe: @29
                          srcp: ctors_orig.cpp:6        private
                          size: @43      algn: 32       bpos: @44
@35     function_decl    name: @40      type: @45      scpe: @29
                          srcp: ctors_orig.cpp:2        member
                          public         constructor    args: @46
                          extern
@36     binfo            type: @29      bases: 0
@37     compound_stmt    line: 13       body: @47
@38     call_expr        type: @15      fn  : @48      args: @49
@39     decl_stmt        line: 14       decl: @50      next: @51
@40     identifier_node  strg: no_default_ctor         lngt: 15
@41     identifier_node  strg: m_i      lngt: 3
@42     integer_type     qual: c        name: @11      unql: @7
                          size: @52      algn: 32       prec: 32
                          min : @53      max : @54
@43     integer_cst      type: @10      low : 32
@44     integer_cst      type: @10      low : 0
@45     method_type      size: @6       algn: 64       clas: @29
                          retn: @15      prms: @55
@46     parm_decl        name: @56      type: @57      scpe: @35
                          srcp: ctors_orig.cpp:2        artificial
                          argt: @57      size: @58      algn: 32
                          used: 0
@47     expr_stmt        line: 13       expr: @59
@48     addr_expr        type: @60      op 0: @61
@49     tree_list        valu: @62
@50     var_decl         name: @63      type: @29      scpe: @1
                          srcp: ctors_orig.cpp:14       size: @30
                          algn: 32       used: 1
@51     expr_stmt        line: 14       expr: @64      next: @65
@52     integer_cst      type: @10      low : 32
@53     integer_cst      type: @7       high: -1       low : -2147483648
@54     integer_cst      type: @7       low : 2147483647
@55     tree_list        valu: @66      chan: @67
@56     identifier_node  strg: this     lngt: 4
@57     pointer_type     qual: c        unql: @66      size: @68
                          algn: 32       ptd : @29
@58     integer_cst      type: @10      low : 32
@59     call_expr        type: @15      fn  : @69      args: @70
@60     pointer_type     size: @58      algn: 32       ptd : @71
@61     function_decl    name: @72      mngl: @73      type: @71
                          scpe: @29      srcp: ctors_orig.cpp:3
                          member         public         destructor
                          args: @74      extern
@62     nop_expr         type: @66      op 0: @75
@63     identifier_node  strg: Anint    lngt: 5
@64     stmt_expr        type: @15      stmt: @76
@65     cleanup_stmt     line: 14       decl: @50      expr: @77
                          next: @78
@66     pointer_type     size: @58      algn: 32       ptd : @29
@67     tree_list        valu: @7       chan: @8
@68     integer_cst      type: @10      low : 32
@69     addr_expr        type: @79      op 0: @80
@70     tree_list        valu: @81      chan: @82
@71     method_type      size: @6       algn: 64       clas: @29
                          retn: @15      prms: @83
@72     identifier_node  strg: __comp_dtor             lngt: 11
@73     identifier_node  strg: _ZN15no_default_ctorD1Ev
                          lngt: 24
@74     parm_decl        name: @56      type: @57      scpe: @61
                          srcp: ctors_orig.cpp:3        artificial
                          argt: @57      size: @58      algn: 32
                          used: 0
@75     nop_expr         type: @66      op 0: @84
@76     compound_stmt    line: 14       body: @85
@77     call_expr        type: @15      fn  : @86      args: @87
@78     expr_stmt        line: 15       expr: @88      next: @89
@79     pointer_type     size: @58      algn: 32       ptd : @45
@80     function_decl    name: @90      mngl: @91      type: @45
                          scpe: @29      srcp: ctors_orig.cpp:2
                          member         public         constructor
                          args: @92      extern
@81     addr_expr        type: @66      op 0: @26
@82     tree_list        valu: @93
@83     tree_list        valu: @66      chan: @8
@84     addr_expr        type: @66      op 0: @26
@85     expr_stmt        line: 14       expr: @94
@86     addr_expr        type: @60      op 0: @61
@87     tree_list        valu: @95
@88     convert_expr     type: @15      op 0: @96
@89     expr_stmt        line: 16       expr: @97      next: @98
@90     identifier_node  strg: __comp_ctor             lngt: 11
@91     identifier_node  strg: _ZN15no_default_ctorC1Ei
                          lngt: 24
@92     parm_decl        name: @56      type: @57      scpe: @80
                          srcp: ctors_orig.cpp:2        artificial
                          argt: @57      size: @58      algn: 32
                          used: 0
@93     integer_cst      type: @7       low : 3
@94     call_expr        type: @15      fn  : @99      args: @100
@95     nop_expr         type: @66      op 0: @101
@96     target_expr      type: @29      decl: @102     init: @103
                          clnp: @104
@97     convert_expr     type: @15      op 0: @105
@98     scope_stmt       line: 17       end            clnp
@99     addr_expr        type: @60      op 0: @106
@100    tree_list        valu: @107
@101    nop_expr         type: @66      op 0: @108
@102    var_decl         type: @29      scpe: @1       srcp: 
ctors_orig.cpp:15
                          artificial     size: @30      algn: 32
                          used: 0
@103    compound_expr    type: @29      op 0: @109     op 1: @102
@104    call_expr        type: @15      fn  : @110     args: @111
@105    target_expr      type: @29      decl: @112     init: @50
                          clnp: @113
@106    function_decl    name: @90      mngl: @114     type: @71
                          scpe: @29      srcp: ctors_orig.cpp:5
                          member         private        constructor
                          args: @115     undefined      extern
@107    addr_expr        type: @66      op 0: @50
@108    addr_expr        type: @66      op 0: @50
@109    call_expr        type: @15      fn  : @116     args: @117
@110    addr_expr        type: @60      op 0: @61
@111    tree_list        valu: @118
@112    var_decl         type: @29      scpe: @1       srcp: 
ctors_orig.cpp:16
                          artificial     size: @30      algn: 32
                          used: 0
@113    call_expr        type: @15      fn  : @119     args: @120
@114    identifier_node  strg: _ZN15no_default_ctorC1Ev
                          lngt: 24
@115    parm_decl        name: @56      type: @57      scpe: @106
                          srcp: ctors_orig.cpp:5        artificial
                          argt: @57      size: @58      algn: 32
                          used: 0
@116    addr_expr        type: @79      op 0: @80
@117    tree_list        valu: @121     chan: @122
@118    nop_expr         type: @66      op 0: @123
@119    addr_expr        type: @60      op 0: @61
@120    tree_list        valu: @124
@121    addr_expr        type: @66      op 0: @102
@122    tree_list        valu: @125
@123    nop_expr         type: @66      op 0: @126
@124    nop_expr         type: @66      op 0: @127
@125    integer_cst      type: @7       low : 3
@126    addr_expr        type: @66      op 0: @102
@127    nop_expr         type: @66      op 0: @128
@128    addr_expr        type: @66      op 0: @112

Is this clear to anyone?  Is there a doc somewhere which tells me
how to read this output?

Many thank-yous,
David




More information about the Gcc-help mailing list