factor / factor

Factor programming language

Home Page:https://factorcode.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

super slow compilation working with libclang

erg opened this issue · comments

main-libclang-bug branch

It's much slower to compile with the 2) "slow compilation" code in than with 1). I thought it was hanging the compiler but it just takes a lot longer.

it happens in backend in optimize-cfg and finalize-cfg

USE: libclang

: cxreturn-type>factor ( type -- string )
    {
        { [ dup kind>> CXType_Pointer = ] [
            clang_getPointeeType cxreturn-type>factor "*" append
        ] }
        { [ dup kind>> CXType_Elaborated = ] [
            ! 1) fast compilation
            ! clang_getCanonicalType dup kind>> CXType_Record = [
            !     ! "canon" g... dup g...
            !     clang_getCString
            ! ] when kind>> cxprimitive-type>factor

            ! 2) slow compilation
            clang_getCanonicalType dup kind>> CXType_Record = [
                "canon" g... dup g...
                clang_getCString
            ] [ kind>> cxprimitive-type>factor ] if
        ] }
        ! { [ dup kind>> CXType_Record = ] [
        !     drop ""
        ! ] }
        [ kind>> cxprimitive-type>factor ]
    } cond ;
disable-optimizer
USE: libclang

! paste def
: cxreturn-type>factor ( type -- string )
    {
        { [ dup kind>> CXType_Pointer = ] [
            clang_getPointeeType cxreturn-type>factor "*" append
        ] }
        { [ dup kind>> CXType_Elaborated = ] [
            ! 1) fast compilation
            ! clang_getCanonicalType dup kind>> CXType_Record = [
            !     ! "canon" g... dup g...
            !     clang_getCString
            ! ] when kind>> cxprimitive-type>factor

            ! 2) slow compilation
            clang_getCanonicalType dup kind>> CXType_Record = [
                "canon" g... dup g...
                clang_getCString
            ] [ kind>> cxprimitive-type>factor ] if
        ] }
        ! { [ dup kind>> CXType_Record = ] [
        !     drop ""
        ! ] }
        [ kind>> cxprimitive-type>factor ]
    } cond ;

\ optimize-cfg breakpoint

enable-optimizer

{ cxreturn-type>factor } recompile

looks like split-branches is the first slow one. this is because the cfg has 63k+ nodes (bug)


=== Basic block #63964 (k)

     ##safepoint
     ##epilogue
     ##jump cxprimitive-type>factor