Announcement

Collapse
No announcement yet.

Firefox Is Now Built With Clang+LTO Everywhere, Sizable Performance Wins For Linux

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

  • #41
    Originally posted by hubicka View Post
    Comparing LTO+PGO between bth compilers seems to favour GCC.
    I am building Firefox with LTO+PGO using GCC regularly. Usually linker errors are just missing attribute ((used)) on variables used by toplevel asm statements.
    Have these been reported to Mozilla?

    Comment


    • #42
      If the correct code is miscompiled/not compiled by GCC with LTO, you recommend us to annotate code with attribute ((used)) and other attributes?

      No, nobody is going to waste time to do it.


      Comment


      • #43
        Originally posted by pyler View Post
        If the correct code is miscompiled/not compiled by GCC with LTO, you recommend us to annotate code with attribute ((used)) and other attributes?

        No, nobody is going to waste time to do it.

        The code is wrong. The only reason you don't get the same failures with clang is because they optimize less aggressively, but that can change any release. Fixing bugs now is better than waiting for them to become a problem.

        Comment


        • #44
          Originally posted by pyler View Post
          If the correct code is miscompiled/not compiled by GCC with LTO, you recommend us to annotate code with attribute ((used)) and other attributes?
          Your fallacy is that you think this is "correct code" when it's not.

          There's no guarantee in the standard that a variable or function or whatever that is not used will even exist at all in the output. If you use top level asms and other hacks like that and don't mark them as used, GCC will remove them, rightfully. The attribute is meant to tell the compiler that the thing in question is actually used, despite nothing referencing it in some way (except for hacks of course), so it should not discard it.

          Removing unused stuff is normal compiler behavior, and has nothing to do with LTO. It breaks with LTO because, with LTO, the compiler can truly see that it really is not used (since it can "see" in all the source files). This stinks of bad design to me: designed by someone who thinks that LTO doesn't exist and that all files are compiled "separately".

          In other words: the code is just bad and makes bad assumptions and whoever wrote it should feel bad.

          Comment


          • #45
            Originally posted by Tomin View Post

            Have these been reported to Mozilla?
            The benchmarks was done by Mozilla folks, so yes.

            Comment


            • #46
              Originally posted by Weasel View Post
              Your fallacy is that you think this is "correct code" when it's not.
              ...
              Yes, but it is not hard for GCC to check inline asm statements and check if the "unused" function is not called there. Not sure, does GCC issue warning in this case? If so, yes, Mozilla devs should pay more attention on errors and if they ignore them, GCC has right to remove it.

              But anyway, what is the result of such removal? Broken build because you are too aggresive.

              Comment


              • #47
                Originally posted by pyler View Post
                Yes, but it is not hard for GCC to check inline asm statements and check if the "unused" function is not called there. Not sure, does GCC issue warning in this case? If so, yes, Mozilla devs should pay more attention on errors and if they ignore them, GCC has right to remove it.
                GCC doesn't parse asm statement templates (the string). You need to specify it as an operand and then sure enough it will work. That's proper code. Otherwise it's just a hack.

                Originally posted by pyler View Post
                But anyway, what is the result of such removal? Broken build because you are too aggresive.
                I don't see why a compiler should punish correctly written applications by being "less aggressive" (it will optimize less) because some dumbies use hacks they don't understand the consequences of.

                Comment


                • #48
                  Originally posted by Weasel View Post
                  GCC doesn't parse asm statement templates (the string). You need to specify it as an operand and then sure enough it will work. That's proper code. Otherwise it's just a hack.
                  Yeah. It's pretty standard for compilers to require that inline assembly specify its operands and scratch space separately so the optimizer will know to work around them.

                  Here's the syntax, as given in the GCC manual:

                  Code:
                  asm [volatile] ( AssemblerTemplate
                                   : OutputOperands
                                   [ : InputOperands
                                   [ : Clobbers ] ])
                  
                  asm [volatile] goto ( AssemblerTemplate
                                        :
                                        : InputOperands
                                        : Clobbers
                                        : GotoLabels)

                  Comment


                  • #49
                    Default Firefox 62 on OpenMandriva Lx 3. This distro build all (almost all) package with Clang from long time. If you want look how Firefox working with Clang just test it. Proof Firefox build with Clang: https://imgur.com/a/fZTRWVo

                    Comment

                    Working...
                    X