IBM Support

IZ45794: RECURSIVE TEMPLATE HANG AT -O3

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • Compiling the following test case which includes recursive
    template instantiations at -O3 will cause very long compilation
    time or a hang.
    
    TESTCASE:
    
    #include <cstddef>
    
    enum TKId{ I4, I8, R4, R8 };
    typedef int ESMC_I4;
    typedef long long ESMC_I8;
    typedef float ESMC_R4;
    
    typedef double ESMC_R8;
    
    
    
    
    //-------------------------------------------------------------
    
    template<typename T, typename U, typename V>
    void psv(T *element, TKId elementTK, U *factorList, TKId
    factorTK,
     V *valueList, TKId valueTK, int resolved){
     // Recursively resolve the TKs and typecast the arguments
    appropriately
     // before executing psv operation on the data.
     if (resolved==0){
         resolved;
       switch (elementTK){
       case I4:
         {
           ESMC_I4 *elementT = (ESMC_I4 *)element;
           psv(elementT, elementTK, factorList, factorTK, valueList,
    valueTK,
             resolved);
         }
         break;
       case I8:
         {
           ESMC_I8 *elementT = (ESMC_I8 *)element;
           psv(elementT, elementTK, factorList, factorTK, valueList,
    valueTK,
             resolved);
         }
         break;
       case R4:
         {
           ESMC_R4 *elementT = (ESMC_R4 *)element;
           psv(elementT, elementTK, factorList, factorTK, valueList,
    valueTK,
             resolved);
         }
         break;
       case R8:
         {
           ESMC_R8 *elementT = (ESMC_R8 *)element;
           psv(elementT, elementTK, factorList, factorTK, valueList,
    valueTK,
             resolved);
         }
         break;
       default:
         break;
       }
       return;
     }
     if (resolved==1){
         resolved;
       switch (factorTK){
       case I4:
         {
           ESMC_I4 *factorListT = (ESMC_I4 *)factorList;
           psv(element, elementTK, factorListT, factorTK, valueList,
    valueTK,
             resolved);
         }
         break;
       case I8:
         {
           ESMC_I8 *factorListT = (ESMC_I8 *)factorList;
           psv(element, elementTK, factorListT, factorTK, valueList,
    valueTK,
             resolved);
         }
         break;
       case R4:
         {
           ESMC_R4 *factorListT = (ESMC_R4 *)factorList;
           psv(element, elementTK, factorListT, factorTK, valueList,
    valueTK,
             resolved);
         }
         break;
       case R8:
         {
           ESMC_R8 *factorListT = (ESMC_R8 *)factorList;
           psv(element, elementTK, factorListT, factorTK, valueList,
    valueTK,
             resolved);
         }
         break;
       default:
         break;
       }
       return;
     }
     if (resolved==2){
         resolved;
       switch (valueTK){
       case I4:
         {
           ESMC_I4 *valueListT = (ESMC_I4 *)valueList;
           psv(element, elementTK, factorList, factorTK, valueListT,
    valueTK,
             resolved);
         }
         break;
       case I8:
         {
           ESMC_I8 *valueListT = (ESMC_I8 *)valueList;
           psv(element, elementTK, factorList, factorTK, valueListT,
    valueTK,
             resolved);
         }
         break;
       case R4:
         {
           ESMC_R4 *valueListT = (ESMC_R4 *)valueList;
           psv(element, elementTK, factorList, factorTK, valueListT,
    valueTK,
             resolved);
         }
         break;
       case R8:
         {
           ESMC_R8 *valueListT = (ESMC_R8 *)valueList;
           psv(element, elementTK, factorList, factorTK, valueListT,
    valueTK,
             resolved);
         }
         break;
       default:
         break;
       }
       return;
     }
    }
    
    //--------------------------------------------------------------
    ---
    
    void testTemplate(TKId elementTK, TKId factorTK, TKId valueTK){
     int *element=NULL, *factorList=NULL, *valueList=NULL;
     psv(element, elementTK, factorList, factorTK, valueList,
    valueTK, 0
    );
    }
    

Local fix

  • Instead of typedef double ESMC_R8;
    use typedef float ESMC_R8;
    

Problem summary

  • If compiling a programs with deep recursion and many recursive
    paths at -O3 and higher, the V9 C/C++ compiler tries to visit
    all possible recursive paths in invocation graph.
    
    If the number of possible recursive
    paths gets too large, the compiler will seem to hang.
    

Problem conclusion

  • The compiler is fixed to manage to analyze programs with
    complex invocation grapshs without an exhaustive traversal.
    

Temporary fix

Comments

APAR Information

  • APAR number

    IZ45794

  • Reported component name

    XL C AIX

  • Reported component ID

    5724S7000

  • Reported release

    900

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2009-03-12

  • Closed date

    2009-04-29

  • Last modified date

    2009-04-29

  • APAR is sysrouted FROM one or more of the following:

    LI74130

  • APAR is sysrouted TO one or more of the following:

    LI74732 LI74753

Fix information

  • Fixed component name

    XL C AIX

  • Fixed component ID

    5724S7000

Applicable component levels

  • R900 PSY

       UP

[{"Line of Business":{"code":"LOB08","label":"Cognitive Systems"},"Business Unit":{"code":"BU054","label":"Systems w\/TPS"},"Product":{"code":"SSJT9L","label":"XL C\/C++"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"9.0"}]

Document Information

Modified date:
03 October 2021