Announcement

Collapse
No announcement yet.

LLVM Clang 16 vs. GCC 13 Compiler Performance On Intel Raptor Lake

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • akostadinov
    replied
    Wanted to see what compiles faster, ont the resulting binaries...

    Leave a comment:


  • DanglingPointer
    replied
    When are we getting this... ???
    11.4 vs 12.2 vs 12.3 vs 13.1 vs llvm-15 vs llvm-16
    with:
    • O2
    • O3
    • O2 -flto
    • O3 -flto
    • O3 -flto=thin (llvm)
    • march=native O2
    • march=native O3
    • march=native O2 -flto
    • march=native O3 -flto
    • march=native O3 -flto=thin (llvm)
    ​with AMD​

    Leave a comment:


  • brad0
    replied
    Originally posted by berolinux View Post
    Looks like OpenMandriva's idea of switching the entire OS to building with clang will finally pay off in terms of performance.
    It already has for some time.

    Leave a comment:


  • berolinux
    replied
    Looks like OpenMandriva's idea of switching the entire OS to building with clang will finally pay off in terms of performance.

    Leave a comment:


  • Weasel
    replied
    Originally posted by discordian View Post
    TBH this whole ELF interposition should've never been the default but an explicit opt-in. Its not used anywhere outside of hooking stuff into libc
    It's due to ELF's garbage global symbols. PE in contrast can't even store them. You can still hook there, it just requires more effort, and who cares? Most people who hook are experienced enough for it to not matter, unlike 99.999% of users who will suffer because of ELF's stupid design decisions.

    Leave a comment:


  • brad0
    replied
    Originally posted by Volta View Post
    Does clang compile kernel yet? If not it can lick GCC boots.
    It does and with LTO. GCC is the one licking Clang's boots.

    Leave a comment:


  • Volta
    replied
    marios, discordian

    It would be interesting to see Linux GCC vs Linux Clang then.

    Leave a comment:


  • discordian
    replied
    Originally posted by hubicka View Post

    Both GCC and Clang require -fvisibility=hidden to not export the symbol. Making -fvisibility=hidden a default would break a lot of existing packages that does not mark exported symbols.
    Even more packages wont care, and the remaining deserve to be fixed (the C/C++ standard knows nothing about public/hidden symbols, and depending on compiler historic compiler behavior aint a good idea). TBH, I thought the visibility default were a configuration option when compiling gcc, seems I remembered this wrong - using mostly toolchains with wrappers and buildsystems where -fvisibility=hidden is used transparently.

    Originally posted by hubicka View Post
    If you compile the testcase with -fvisibility=hidden, GCC will optimize return to 1. GCC has quite careful logic about what can be interposed:
    1. Interposition is possible only with -fpic or weak symbols
    1. And that comes with a cost: inefficent code and relocations.
      Originally posted by hubicka View Post
    2. Inline functions or comdats can not be be semantically interposed (but can be interposed to different, equivalent definition possibly optimized with different optimization flags or compiled by other compiler)
    3. With -flto, one can use resolution file to hide symbols at link-time (as you suggest) and GCC will be informed about this (it will see that the symbol is not LDPR_PREVAILING_DEF_IRONLY and optimize accordingly)
    Yep, and that means atleast the call sites need to be compiled/patched - could be simpler than "full" LTO.
    Originally posted by hubicka View Post
  • If you compile with -fpic but link resulting object into non-shared binary, GCC will know this from linker plugin too and disable inteprosition.
Originally posted by hubicka View Post
Problem is that Clang exports the symbol in my testcase yet does not expect the interposition to happen. This is not considered to be a good idea in GCC (as discussed few times at the mailing-list).
I stand corrected then, sounds like a bug.

Leave a comment:


  • hubicka
    replied
    Originally posted by discordian View Post

    The example you provided contained a function that is not marked to be exported, so ELF interposition is not an argument. Which functions are eligible to be exported is not standardized, the sane thing to do would add a macro notifying that. gcc leaves valid optimizations on the table, unless your example is missing some crucial details.

    (in an ideal world, the information how the symbol is to be used comes from the linker and not marks in the source-code, requiring at least some mild form of LTO or turning the build-process upside-down)
    Both GCC and Clang require -fvisibility=hidden to not export the symbol. Making -fvisibility=hidden a default would break a lot of existing packages that does not mark exported symbols.

    If you compile the testcase with -fvisibility=hidden, GCC will optimize return to 1. GCC has quite careful logic about what can be interposed:
    1. Interposition is possible only with -fpic or weak symbols
    2. Inline functions or comdats can not be be semantically interposed (but can be interposed to different, equivalent definition possibly optimized with different optimization flags or compiled by other compiler)
    3. With -flto, one can use resolution file to hide symbols at link-time (as you suggest) and GCC will be informed about this (it will see that the symbol is not LDPR_PREVAILING_DEF_IRONLY and optimize accordingly)
    4. If you compile with -fpic but link resulting object into non-shared binary, GCC will know this from linker plugin too and disable inteprosition.

    Problem is that Clang exports the symbol in my testcase yet does not expect the interposition to happen. This is not considered to be a good idea in GCC (as discussed few times at the mailing-list).

    Leave a comment:


  • discordian
    replied
    Originally posted by hubicka View Post

    -fno-semantic-interposition is not an optimization. It is flag telling compiler to ignore ELF interposition rules. Doing so enables other optimizations (such as inlining, constant propagation etc.). GCC at -O3 optimization levels should be standard conforming (with few well justified exceptions), so enabling semantic interposition would need agreement outside of GCC community on updating ELF standard.
    The example you provided contained a function that is not marked to be exported, so ELF interposition is not an argument. Which functions are eligible to be exported is not standardized, the sane thing to do would add a macro notifying that. gcc leaves valid optimizations on the table, unless your example is missing some crucial details.

    (in an ideal world, the information how the symbol is to be used comes from the linker and not marks in the source-code, requiring at least some mild form of LTO or turning the build-process upside-down)
    Last edited by discordian; 12 May 2023, 07:49 AM.

    Leave a comment:

  • Working...
    X