LLVM and the future of optimization

后端 未结 7 1844
被撕碎了的回忆
被撕碎了的回忆 2021-02-19 07:11

I realize that LLVM has a long way to go, but theoretically, can the optimizations that are in GCC/ICC/etc. for individual languages be applied to LLVM byte code? If so, does t

7条回答
  •  梦如初夏
    2021-02-19 08:01

    I addition to Dietrich's excellent answer, I think it is important to appreciate that it is not just the compiler that determines how fast programming languages are. In addition to the various optimizations that a given language may allow/disallow, there is also the matter of how you do certain tasks in various programming languages and what the language lets you do.

    For example, it is relatively easy to optimize C code to maximize cache efficiency (reducing slow reads from memory) while this is much harder in Haskell. Pointer hacks are impossible in Java. As is the strategy of allocating a huge chunk of memory and parceling it out by hand.

    Thus, some languages will always be slower simply because they don't allow for the same level of optimization. Note that I'm not necessarily saying that this is a bad thing because with that slowness come extremely powerful constructs.

    I think that a better way to look at it is that LLVM will allow for a certain set of optimizations to be applied to all languages that compile down to it. Thus, while it will make such languages faster, it will not make them equally fast.

    Edit: Pointer hacks in Haskell. So many possibilities ...

提交回复
热议问题