[cfe-dev] [llvm-dev] is LLVM IR suitable for your library Optimization?

Chris Lattner via cfe-dev cfe-dev at lists.llvm.org
Wed Mar 13 23:00:29 PDT 2019


<moving cfe-dev to BCC to reduce crossposting>

It is perfectly possible to do library level optimization on LLVM IR, if you library has very close to the C API.  LLVM has a bunch of stuff that does this, e.g. optimizations for strcat, strcmp, etc.

That said, doing optimizations on high level language abstractions (e.g. std::vector or std::shared_pointer or Swift.Array) is probably *possible* but is not great, because much of the target-specific ABI details get lowered out into LLVM IR, which makes pattern matching on the IR target specific and fragile. 

Beyond that, optimizations on (for example) C++ types want to think about concepts like “copy constructors” language rules which aren’t preserved perfectly in LLVM IR.

It is important to know that MLIR *is* a three address SSA IR like LLVM, it is just that the type system and operations are dialect defined instead of being hard coded.

-Chris



> On Mar 13, 2019, at 6:26 PM, dalas via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> Hi, One question got in my head recently from the slides "MLIR Primer : A Compiler Infrastructure for the End of Moore's Law"
> 
> When trying to optimize the source code based on LLVM IR, Do the compiler developers and the SW Library developers feel enough to improve easily? Wouldn't it be hard for them to handle the Low-Level IR to optimize? This question kept in my mind because I can't catch the capability whether the LLVM IR is the best optimization Intermediate Language for Library Developer. Mostly the Library optimization is switching the Function, Function Parameters, Loop unrolling, etc. Does it really need to be done with SSA-form, RISC-like IR format to do all these? If there is a more C-like or C++-like IR, wouldn't it be more easy for Library Maintainer, such as ML Developer, Math Library, MultiThreading Library, etc?
> 
> 
> So I want to know what the practical developers feel about the current LLVM IR form to perform various optimization. Whether the RISC-like IR is better for the higher-level Optimization skills. Thanks for reading and answering the question. Peace Out!
> 
> 
> P.S. This question is not intended to discourage the LLVM IR development, but just pops up the talk on whether there could be more better solution on Clang Environment.
> 
> 
> 
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev




More information about the cfe-dev mailing list