📜 ⬆️ ⬇️

LLVM 3.3 Official Release

For those who do not follow closely the development of Clang / LLVM, I inform you - release of version 3.3 has taken place. LLVM continues to evolve in leaps and bounds and, as stated, is the first to support all C ++ 11 features, added support for a whole bunch of new targets, and several interesting features appeared based on the LLVM infrastructure. The optimizer also continues to evolve - an auto vectorizer appeared, which works by default on -O3, a lot has been done to improve the already existing optimizations. Who are interested in the details - welcome under cat.

Let's start with C ++ 11 support. Full support has been claimed, including library support for important features such as std :: regex. The completion of work on C ++ 11 in a trunk was announced in the LLVM blog in April and now the front-end developers are busy working on supporting the draft of the next standard called C ++ 1y. They say that after the release of C ++ 11 there were several annoying flaws, Bjarne Straustrup stated that he would not release a new standard until all the features were implemented in at least one compiler. So it remains only to welcome the activity of the developers of clang.

For those who are ready to start using C ++ 11 right now in existing projects, a special C ++ 11 Migration Tool is offered. With this utility, you can automatically convert old cycles into range-based for cycles, arrange for using nullptr instead of initializing pointers to zeros, change the type in variable declarations to auto where appropriate, and add override to virtual function declarations. It is gratifying to note that this tool was developed by Intel employees, who are beginning to invest more and more in LLVM along with Apple and Google.
')
Another interesting tool that has become possible due to the openness and extensibility of Clang is clang-format . It allows you to format the source code according to a given style, but at the same time differs from its counterparts in that, using the various components of Clang, it receives information about the syntactic structure of the code, sufficient for complete reformatting, almost without focusing on the original formatting (with rare exceptions: it can leave blank lines separating the logical blocks of code, and save the comment binding to commented entities). At the same time, clang-format does not use the entire Clang parser, which allows it to be used for any source code fragments, similar to the correct C ++ code. And if at the time of C it was possible to do with relatively simple approaches, then the abundance of syntactic structures in C ++ and their dependence on the context require a sufficiently deep understanding of the code from such a tool. Who cares about the details, I recommend watching the video from the conference, where one of the developers talks about this tool: conference materials , look for “clang-format - Automatic formatting for C ++”. By the way, also available are plugins for Vim and Emacs, which allow you to format the text on the fly.

The optimizer also added well. The main innovation is the auto-vectorizer cycles, enabled by default on -O3. As you know, a little less than a year ago, Apple began to actively promote the creation of the vectorizer and now we can observe the first fruits of these efforts. Objectively assessing the status of the project, it is worth noting that, although up to the best available on the market avtovektorizator for x86 (implemented in Intel Compiler) even at best, many years of development and competition with GCC is also not in favor of a beginner, but even a relatively simple solution can give the user noticeable benefits. After all, as you know, 80% of the result is achieved 20% of the effort. And let them not kick me for affinity with Intel, I think many would agree with this assessment.

Enumerating smaller improvements in optimizations is pointless. Just to say that in terms of scalar optimizations, Clang is ready to argue with GCC, and with Intel Compiler, and sometimes beat these optimization bison. LTO (link time optimizations) is also doing well, but while the results are good, one of the architects acknowledges that there are fundamental problems that have yet to be resolved. Intrigued by such a bold statement, I advise you to look at Comrade Chandler’s keynote "Optimization in LLVM - Numbers, A Case Study, and Looking Forward" at the same conference .

The Release Notes surprisingly bypassed one of Clang's greatest strengths - its unsurpassed accuracy and detailed diagnostics, which they continue to work on (let’s say frankly, against the background of such a competitor, the GCC developers felt embarrassed and also added well in this direction). In the family of dynamic code verification tools, so-called sanitizers, there is also an addition - in addition to Address- and Thread-, MemorySanitizer was added. For those who use static code checking, too, the good news is that the Clang Static Analyzer now supports several new types of checks and can walk across the C ++ boundaries of designers and destructors.

The new release has added support for new targets, the most notable of which are AArch64 and AMD R600 GPU. IBM's z / Architecture S390 is also on the list - I think support for such an architecture is already an application for compiler maturity. Someone may be interested in a seriously improved PowerPC back-end and MIPS support.

Official Release Notes are available here , and the compiler for various platforms can be downloaded here .

Source: https://habr.com/ru/post/183774/


All Articles