Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

super slow compilation working with libclang #2926

Open
erg opened this issue Dec 14, 2023 · 1 comment
Open

super slow compilation working with libclang #2926

erg opened this issue Dec 14, 2023 · 1 comment

Comments

@erg
Copy link
Member

erg commented Dec 14, 2023

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 ;
@erg
Copy link
Member Author

erg commented Dec 14, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant