LLVM Optimization Remarks - Ofek Shilon - CppCon 2022

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 ส.ค. 2024
  • cppcon.org/
    ---
    LLVM Optimization Remarks - Helping the Compiler Generate Better Code - Ofek Shilon - CppCon 2022
    github.com/Cpp...
    Optimization remarks are Clang's logs of optimization passes, which include leads into optimization failures that might be mitigated. Deciphering raw optimization remarks seems a matter for compiler authors and select few experts, but a little-known tool called opt-viewer aims to change that - in particular with recent improvements by myself and others.
    About 50% of the talk would be dedicated to real examples of missed optimizations. Most turn out to be escape-analysis and alias-analysis related, and we will devote time to discuss these in some depth.
    We will also extend the discussion to other compilers and even other languages. (you really can't have a C++ presentation in Sep 2022 without at least mentioning Rust and Carbon).
    If you care about performance there's an excellent chance you'd leave this talk with immediately actionable insights and surprising ways to check and improve your code in performance bottlenecks.
    ---
    Ofek Shilon
    20Y C++ developer, writer and speaker in both the Linux and MS universes. Fascinated by compilers, debuggers and pretty much anything low level. Fiercely hated by his cat for no apparent reason.
    ---
    Videos Filmed & Edited by Bash Films: www.BashFilms.com
    TH-cam Channel Managed by Digital Medium Ltd events.digital...
    #cppcon #programming #llvm

ความคิดเห็น • 33

  • @casperes0912
    @casperes0912 ปีที่แล้ว +19

    This man talks like a very good university professor

  • @glorioussir9673
    @glorioussir9673 ปีที่แล้ว +12

    Very useful talk, thank you! If programmers were taught this stuff we would live in a better world...

  • @momoanddudu
    @momoanddudu ปีที่แล้ว +5

    Excellent lecture! I enjoyed it and learned a lot. Thank you!
    Regarding the third example, declaring somefunc to be constexpr (passing the argument by const reference doesn't preclude the possibility of doing so) would be a standard way to declare it pure.

  • @RadimPolasek
    @RadimPolasek ปีที่แล้ว +7

    great presentation, thank you

  • @piotrarturklos
    @piotrarturklos ปีที่แล้ว +2

    This is awesome, I can't wait to make use of it at work.

  • @till8413
    @till8413 ปีที่แล้ว +6

    exciting!

  • @benjaminshinar9509
    @benjaminshinar9509 ปีที่แล้ว +1

    great talk!
    I was surprised by how much of it I could follow 😁

  • @zxuiji
    @zxuiji ปีที่แล้ว +2

    17:37, there's a better solution to __restrict__, remove that unnecessary & symbol from b

  • @LeDabe
    @LeDabe ปีที่แล้ว +5

    Great.

  • @pietro7121
    @pietro7121 ปีที่แล้ว +1

    This was a very nice talk, but why the incredible handsome man near the airplane in the first slide?

  • @ProfessorWaltherKotz
    @ProfessorWaltherKotz ปีที่แล้ว +2

    52:50 Fedor Pikus is such a C++ mastermind... omg

  • @williamdavidwallace3904
    @williamdavidwallace3904 ปีที่แล้ว +2

    The absolute most important thing to help the optimizer produce code that works is to write C or C++ code. In both languages it is possible to easily write code that is nearly correct but has undefined behavior in the standard. The optimizer may well produce totally bad object code in such cases. The compiler is often not required to diagnose such situations.

  • @BalanNarcis
    @BalanNarcis ปีที่แล้ว

    Awesome feature! Great talk, thank you!

  • @simonhrabec9973
    @simonhrabec9973 ปีที่แล้ว +3

    It would be nice to have the links from the presentation also in the description.

    • @abuyoyo31
      @abuyoyo31 ปีที่แล้ว +1

      Just added a link in a comment

    • @abuyoyo31
      @abuyoyo31 ปีที่แล้ว

      Just tried again

  • @origamibulldoser1618
    @origamibulldoser1618 ปีที่แล้ว +1

    Perfect talk imo

  • @antonbikineev8587
    @antonbikineev8587 ปีที่แล้ว

    Amazing talk, thanks

  • @Moriadin
    @Moriadin ปีที่แล้ว

    excellent talk!

  • @simonhrabec9973
    @simonhrabec9973 ปีที่แล้ว

    Great talk!

  • @dark808bb8
    @dark808bb8 ปีที่แล้ว

    Very interesting

  • @davidsicilia5316
    @davidsicilia5316 ปีที่แล้ว

    great talk

  • @mohammadmahdifarnia5358
    @mohammadmahdifarnia5358 ปีที่แล้ว

    20:25 I saw earlier that const variables are protected by mprotect function and modifying the const variable causes seg fault in program! I confused..

    • @el__nora
      @el__nora ปีที่แล้ว +6

      no, Ofek answers this specifically later on towards the end.
      if the original variable was created mutable, and then was later made const, then modifying it through indirect access (or even just const_casting away) is not UB. since the compiler has no idea how that variable was created, it could be perfectly fine to modify it, and it cannot rule out the possibility that it will be modified.

    • @mohammadmahdifarnia5358
      @mohammadmahdifarnia5358 ปีที่แล้ว

      @@el__nora 👌 54:07

  • @dexterman6361
    @dexterman6361 ปีที่แล้ว

    33:46 wait whaaatt? omg how is that possible

    • @masheroz
      @masheroz ปีที่แล้ว +1

      The method is const, so you can't modify what the pointer points to, but that doesn't mean you can't modify what it points to.
      And you aren't modifying the int member by name, you're "just" changing the information contained at the address that it owns.
      I think.

    • @abuyoyo31
      @abuyoyo31 ปีที่แล้ว +1

      I actually learnt at the conference that this is UB - but no compiler will ever be able to detect it.

    • @Peregringlk
      @Peregringlk 6 หลายเดือนก่อน

      Think that no attribute of the class has been modified. The object contains a pointer, and the pointer has not been modified, and the pointed-to object is not const. In other words, if I memcpy the object to a buffer, call the method, and memcpy the object again, both buffer will compare equal. So that's further proof the method does not modify the object, but objects that lives somewhere else.

  • @zxuiji
    @zxuiji ปีที่แล้ว

    Here's one thing I don't get, why is on the compiler to do the optimisations? why can't we just produce debug objects only and then tell the linker what type of binary we want to produce, a debug binary, a striped down release binary, a profiled binary, all of those should be the linker's job to produce from the objects we generate, not the compiler's job, since the linker would have access to all the information it would need to identify if some functions could be made smaller as it could go off to the definition of a function and see what it modifies.

    • @stragerneds
      @stragerneds ปีที่แล้ว +2

      That is called LTO or LTCG.

    • @niklkelbon3662
      @niklkelbon3662 7 หลายเดือนก่อน

      Lineker have no information about language semantic, so it should only link. Compiler + single .obj (unity build), that may be useful for you