Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changeset 821

Show
Ignore:
Timestamp:
12/27/10 07:46:27 (14 years ago)
Author:
walter
Message:

bugzilla 3681 ICE(go.c): when function takes too long to optimize, only with -O.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/dmd-1.x/src/backend/cdef.h

    r618 r821  
    120120 */ 
    121121 
    122122/* Solaris Version 
    123123 * ------------- 
    124124 * There are two main issues: hosting the compiler on Solaris, 
    125125 * and generating (targetting) Solaris executables. 
    126126 * The "__sun", "__SVR4" and "__GNUC__" macros control hosting issues 
    127127 * for operating system and compiler dependencies, respectively. 
    128128 * To target Solaris executables, use ELFOBJ for things specific to the 
    129129 * ELF object file format, and TARGET_SOLARIS for things specific to 
    130130 * the Solaris memory model. 
    131131 * If this is all done right, one could generate a Solaris object file 
    132132 * even when compiling on win32, and vice versa. 
    133133 * The compiler source code currently uses these macros very inconsistently 
    134134 * with these goals, and should be fixed. 
    135135 */ 
    136136 
    137137#ifndef CDEF_H 
    138138#define CDEF_H  1 
    139139 
    140 #define VERSION "8.53.0"        // for banner and imbedding in .OBJ file 
    141 #define VERSIONHEX "0x853"      // for __DMC__ macro 
    142 #define VERSIONINT 0x853        // for precompiled headers and DLL version 
     140#define VERSION "8.54.0"        // for banner and imbedding in .OBJ file 
     141#define VERSIONHEX "0x854"      // for __DMC__ macro 
     142#define VERSIONINT 0x854        // for precompiled headers and DLL version 
    143143 
    144144 
    145145/*********************************** 
    146146 * Target machine types: 
    147147 */ 
    148148 
    149149#define TX86            1               // target is Intel 80X86 processor 
    150150#define TARGET_68K      0               // target is a 68K processor 
    151151#define TARGET_POWERPC  0               // target is a PPC processor 
    152152#define TARGET_MAC      0               // target is a macintosh 
    153153 
    154154// Set to 1 using the makefile 
    155155#ifndef TARGET_LINUX 
    156156#define TARGET_LINUX    0               // target is a linux executable 
    157157#endif 
    158158 
    159159// Set to 1 using the makefile 
    160160#ifndef TARGET_OSX 
    161161#define TARGET_OSX      0               // target is an OSX executable 
    162162#endif 
  • branches/dmd-1.x/src/backend/el.c

    r807 r821  
    18701870 
    18711871            default: 
    18721872                break; 
    18731873        } 
    18741874        break; 
    18751875    } 
    18761876    return result; 
    18771877} 
    18781878 
    18791879/******************************** 
    18801880 * Scan down commas and return the controlling elem. 
    18811881 */ 
    18821882 
    18831883elem *el_scancommas(elem *e) 
    18841884{ 
    18851885    while (e->Eoper == OPcomma) 
    18861886        e = e->E2; 
    18871887    return e; 
    18881888} 
    18891889 
     1890/*************************** 
     1891 * Count number of commas in the expression. 
     1892 */ 
     1893 
     1894int el_countCommas(elem *e) 
     1895{   int ncommas = 0; 
     1896    while (1) 
     1897    { 
     1898        if (EBIN(e)) 
     1899        { 
     1900            ncommas += (e->Eoper == OPcomma) + el_countCommas(e->E2); 
     1901        } 
     1902        else if (EUNA(e)) 
     1903        { 
     1904        } 
     1905        else 
     1906            break; 
     1907        e = e->E1; 
     1908    } 
     1909    return ncommas; 
     1910} 
     1911 
    18901912#if (TARGET_POWERPC) 
    18911913void el_convconst(elem *e) 
    18921914{ 
    18931915 
    18941916    int i; 
    18951917    symbol *s; 
    18961918    long    *   p; 
    18971919    targ_size_t len; 
    18981920    struct CONST_VALUE { 
    18991921#if !DDRT 
    19001922        long    val[2];                 // Largest floating constant is 8 bytes 
    19011923#else 
    19021924        fix!! 
    19031925#endif 
    19041926        symbol  *s;                     // Symbol for that floating constant 
    19051927    } *pcv; 
    19061928 
    19071929    static list_t value_list; 
    19081930    list_t pcl; 
    19091931 
  • branches/dmd-1.x/src/backend/el.h

    r807 r821  
    154154void el_term(void); 
    155155elem_p el_calloc(void); 
    156156void el_free(elem_p); 
    157157elem_p el_combine(elem_p ,elem_p); 
    158158elem_p el_param(elem_p ,elem_p); 
    159159elem_p el_params(elem_p , ...); 
    160160elem *el_params(void **args, int length); 
    161161int el_nparams(elem *e); 
    162162elem_p el_pair(tym_t, elem_p, elem_p); 
    163163#if TX86 || DEBUG 
    164164void el_copy(elem_p ,elem_p); 
    165165#else 
    166166#define el_copy(to,from) {*(to) = *(from);} 
    167167#endif 
    168168elem_p el_alloctmp(tym_t); 
    169169elem_p el_selecte1(elem_p); 
    170170elem_p el_selecte2(elem_p); 
    171171elem_p el_copytree(elem_p); 
    172172void   el_replace_sym(elem *e,symbol *s1,symbol *s2); 
    173173elem_p el_scancommas(elem_p); 
     174int el_countCommas(elem_p); 
    174175int el_sideeffect(elem_p); 
    175176#if TX86 
    176177int el_depends(elem *ea,elem *eb); 
    177178#endif 
    178179#if LONGLONG 
    179180targ_llong el_tolongt(elem_p); 
    180181targ_llong el_tolong(elem_p); 
    181182#else 
    182183targ_long el_tolongt(elem_p); 
    183184targ_long el_tolong(elem_p); 
    184185#endif 
    185186int el_allbits(elem_p,int); 
    186187int el_signx32(elem_p); 
    187188targ_ldouble el_toldouble(elem_p); 
    188189void el_toconst(elem_p); 
    189190elem_p el_same(elem_p *); 
    190191int el_match(elem_p ,elem_p); 
    191192int el_match2(elem_p ,elem_p); 
    192193int el_match3(elem_p ,elem_p); 
    193194int el_match4(elem_p ,elem_p); 
  • branches/dmd-1.x/src/backend/go.c

    r428 r821  
    216216    cmes ("optfunc()\n"); 
    217217    dbg_optprint("optfunc\n"); 
    218218#ifdef DEBUG 
    219219    if (debugb) 
    220220    { 
    221221        dbg_printf("................Before optimization.........\n"); 
    222222        WRfunc(); 
    223223    } 
    224224#endif 
    225225    iter = 0; 
    226226 
    227227    if (localgot) 
    228228    {   // Initialize with: 
    229229        //      localgot = OPgot; 
    230230        elem *e = el_long(TYnptr, 0); 
    231231        e->Eoper = OPgot; 
    232232        e = el_bin(OPeq, TYnptr, el_var(localgot), e); 
    233233        startblock->Belem = el_combine(e, startblock->Belem); 
    234234    } 
    235235 
     236    // Each pass through the loop can reduce only one level of comma expression. 
     237    // The infinite loop check needs to take this into account. 
     238    int iterationLimit = 200; 
     239    for (b = startblock; b; b = b->Bnext) 
     240    { 
     241        if (!b->Belem) 
     242            continue; 
     243        int d = el_countCommas(b->Belem); 
     244        if (d > iterationLimit) 
     245            iterationLimit = d; 
     246    } 
     247 
    236248    // Some functions can take enormous amounts of time to optimize. 
    237249    // We try to put a lid on it. 
    238250    starttime = clock(); 
    239251    do 
    240252    { 
    241253        //printf("iter = %d\n", iter); 
    242254#if TX86 
    243         //assert(++iter < 80);          /* infinite loop check           */ 
    244         assert(++iter < 200);           /* infinite loop check           */ 
     255        assert(++iter < iterationLimit);           // infinite loop check 
    245256#else 
    246257     L1: 
    247258#endif 
    248259#if MARS 
    249260        util_progress(); 
    250261#else 
    251262        file_progress(); 
    252263#endif 
    253264 
    254265        //printf("optelem\n"); 
    255266        /* canonicalize the trees        */ 
    256267        for (b = startblock; b; b = b->Bnext) 
    257268            if (b->Belem) 
    258269            { 
    259270#if DEBUG 
    260271                if(debuge) 
    261272                { 
    262273                    dbg_printf("before\n"); 
    263274                    elem_print(b->Belem); 
    264275                    //el_check(b->Belem); 
  • trunk/src/backend/cdef.h

    r618 r821  
    120120 */ 
    121121 
    122122/* Solaris Version 
    123123 * ------------- 
    124124 * There are two main issues: hosting the compiler on Solaris, 
    125125 * and generating (targetting) Solaris executables. 
    126126 * The "__sun", "__SVR4" and "__GNUC__" macros control hosting issues 
    127127 * for operating system and compiler dependencies, respectively. 
    128128 * To target Solaris executables, use ELFOBJ for things specific to the 
    129129 * ELF object file format, and TARGET_SOLARIS for things specific to 
    130130 * the Solaris memory model. 
    131131 * If this is all done right, one could generate a Solaris object file 
    132132 * even when compiling on win32, and vice versa. 
    133133 * The compiler source code currently uses these macros very inconsistently 
    134134 * with these goals, and should be fixed. 
    135135 */ 
    136136 
    137137#ifndef CDEF_H 
    138138#define CDEF_H  1 
    139139 
    140 #define VERSION "8.53.0"        // for banner and imbedding in .OBJ file 
    141 #define VERSIONHEX "0x853"      // for __DMC__ macro 
    142 #define VERSIONINT 0x853        // for precompiled headers and DLL version 
     140#define VERSION "8.54.0"        // for banner and imbedding in .OBJ file 
     141#define VERSIONHEX "0x854"      // for __DMC__ macro 
     142#define VERSIONINT 0x854        // for precompiled headers and DLL version 
    143143 
    144144 
    145145/*********************************** 
    146146 * Target machine types: 
    147147 */ 
    148148 
    149149#define TX86            1               // target is Intel 80X86 processor 
    150150#define TARGET_68K      0               // target is a 68K processor 
    151151#define TARGET_POWERPC  0               // target is a PPC processor 
    152152#define TARGET_MAC      0               // target is a macintosh 
    153153 
    154154// Set to 1 using the makefile 
    155155#ifndef TARGET_LINUX 
    156156#define TARGET_LINUX    0               // target is a linux executable 
    157157#endif 
    158158 
    159159// Set to 1 using the makefile 
    160160#ifndef TARGET_OSX 
    161161#define TARGET_OSX      0               // target is an OSX executable 
    162162#endif 
  • trunk/src/backend/el.c

    r807 r821  
    18701870 
    18711871            default: 
    18721872                break; 
    18731873        } 
    18741874        break; 
    18751875    } 
    18761876    return result; 
    18771877} 
    18781878 
    18791879/******************************** 
    18801880 * Scan down commas and return the controlling elem. 
    18811881 */ 
    18821882 
    18831883elem *el_scancommas(elem *e) 
    18841884{ 
    18851885    while (e->Eoper == OPcomma) 
    18861886        e = e->E2; 
    18871887    return e; 
    18881888} 
    18891889 
     1890/*************************** 
     1891 * Count number of commas in the expression. 
     1892 */ 
     1893 
     1894int el_countCommas(elem *e) 
     1895{   int ncommas = 0; 
     1896    while (1) 
     1897    { 
     1898        if (EBIN(e)) 
     1899        { 
     1900            ncommas += (e->Eoper == OPcomma) + el_countCommas(e->E2); 
     1901        } 
     1902        else if (EUNA(e)) 
     1903        { 
     1904        } 
     1905        else 
     1906            break; 
     1907        e = e->E1; 
     1908    } 
     1909    return ncommas; 
     1910} 
     1911 
    18901912#if (TARGET_POWERPC) 
    18911913void el_convconst(elem *e) 
    18921914{ 
    18931915 
    18941916    int i; 
    18951917    symbol *s; 
    18961918    long    *   p; 
    18971919    targ_size_t len; 
    18981920    struct CONST_VALUE { 
    18991921#if !DDRT 
    19001922        long    val[2];                 // Largest floating constant is 8 bytes 
    19011923#else 
    19021924        fix!! 
    19031925#endif 
    19041926        symbol  *s;                     // Symbol for that floating constant 
    19051927    } *pcv; 
    19061928 
    19071929    static list_t value_list; 
    19081930    list_t pcl; 
    19091931 
  • trunk/src/backend/el.h

    r807 r821  
    154154void el_term(void); 
    155155elem_p el_calloc(void); 
    156156void el_free(elem_p); 
    157157elem_p el_combine(elem_p ,elem_p); 
    158158elem_p el_param(elem_p ,elem_p); 
    159159elem_p el_params(elem_p , ...); 
    160160elem *el_params(void **args, int length); 
    161161int el_nparams(elem *e); 
    162162elem_p el_pair(tym_t, elem_p, elem_p); 
    163163#if TX86 || DEBUG 
    164164void el_copy(elem_p ,elem_p); 
    165165#else 
    166166#define el_copy(to,from) {*(to) = *(from);} 
    167167#endif 
    168168elem_p el_alloctmp(tym_t); 
    169169elem_p el_selecte1(elem_p); 
    170170elem_p el_selecte2(elem_p); 
    171171elem_p el_copytree(elem_p); 
    172172void   el_replace_sym(elem *e,symbol *s1,symbol *s2); 
    173173elem_p el_scancommas(elem_p); 
     174int el_countCommas(elem_p); 
    174175int el_sideeffect(elem_p); 
    175176#if TX86 
    176177int el_depends(elem *ea,elem *eb); 
    177178#endif 
    178179#if LONGLONG 
    179180targ_llong el_tolongt(elem_p); 
    180181targ_llong el_tolong(elem_p); 
    181182#else 
    182183targ_long el_tolongt(elem_p); 
    183184targ_long el_tolong(elem_p); 
    184185#endif 
    185186int el_allbits(elem_p,int); 
    186187int el_signx32(elem_p); 
    187188targ_ldouble el_toldouble(elem_p); 
    188189void el_toconst(elem_p); 
    189190elem_p el_same(elem_p *); 
    190191int el_match(elem_p ,elem_p); 
    191192int el_match2(elem_p ,elem_p); 
    192193int el_match3(elem_p ,elem_p); 
    193194int el_match4(elem_p ,elem_p); 
  • trunk/src/backend/go.c

    r428 r821  
    216216    cmes ("optfunc()\n"); 
    217217    dbg_optprint("optfunc\n"); 
    218218#ifdef DEBUG 
    219219    if (debugb) 
    220220    { 
    221221        dbg_printf("................Before optimization.........\n"); 
    222222        WRfunc(); 
    223223    } 
    224224#endif 
    225225    iter = 0; 
    226226 
    227227    if (localgot) 
    228228    {   // Initialize with: 
    229229        //      localgot = OPgot; 
    230230        elem *e = el_long(TYnptr, 0); 
    231231        e->Eoper = OPgot; 
    232232        e = el_bin(OPeq, TYnptr, el_var(localgot), e); 
    233233        startblock->Belem = el_combine(e, startblock->Belem); 
    234234    } 
    235235 
     236    // Each pass through the loop can reduce only one level of comma expression. 
     237    // The infinite loop check needs to take this into account. 
     238    int iterationLimit = 200; 
     239    for (b = startblock; b; b = b->Bnext) 
     240    { 
     241        if (!b->Belem) 
     242            continue; 
     243        int d = el_countCommas(b->Belem); 
     244        if (d > iterationLimit) 
     245            iterationLimit = d; 
     246    } 
     247 
    236248    // Some functions can take enormous amounts of time to optimize. 
    237249    // We try to put a lid on it. 
    238250    starttime = clock(); 
    239251    do 
    240252    { 
    241253        //printf("iter = %d\n", iter); 
    242254#if TX86 
    243         //assert(++iter < 80);          /* infinite loop check           */ 
    244         assert(++iter < 200);           /* infinite loop check           */ 
     255        assert(++iter < iterationLimit);           // infinite loop check 
    245256#else 
    246257     L1: 
    247258#endif 
    248259#if MARS 
    249260        util_progress(); 
    250261#else 
    251262        file_progress(); 
    252263#endif 
    253264 
    254265        //printf("optelem\n"); 
    255266        /* canonicalize the trees        */ 
    256267        for (b = startblock; b; b = b->Bnext) 
    257268            if (b->Belem) 
    258269            { 
    259270#if DEBUG 
    260271                if(debuge) 
    261272                { 
    262273                    dbg_printf("before\n"); 
    263274                    elem_print(b->Belem); 
    264275                    //el_check(b->Belem);