What’s new in LLVM

综合技术 2018-03-10 阅读原文

The LLVM compiler framework
has gone from being a technological curiosity to a vital piece of the modern software landscape. It is the engine behind the Clang compiler, as well as the compilers for the Rust and Swift languages, and provides a powerful toolkit for creating new languages.

It is also a fairly fast-moving project, with major point revisions announced every six months or so. Version 6.0, released earlier this month, continues LLVM’s ongoing mission to deepen and broaden support for a variety of compilation targets. The update also adds many timely fixes to guard against recently discovered processor-level system attacks.

LLVM adds partial Spectre protection

The “Spectre” and “Meltdown” CPU exploits
take advantage of speculative execution features in modern processors. Because they must be addressed by a combination of CPU microcode updates and changes to existing software, they are difficult to fix.

To ensure that applications built with LLVM can do their part to guard against such attacks, LLVM now offers support for ”retpolines,”
a software construction that partly alleviates one of the varieties of the Spectre attack.
To make use of it, you’ll need to use LLVM 6.0 to recompile the software in question using the -mretpoline
command line switch.

LLVM CodeView debugging for Windows improved

Microsoft Windows uses debug information stored in a format called the CodeView format, analogous to the DWARF format used in Linux systems.

LLVM previously added support for working with CodeView
, as part of a general push toward making LLVM a better citizen on Windows
, and leveraging the wealth of debugging tools in Windows that use CodeView.

LLVM 6 further improves that support, thanks to some support from Microsoft and some diligent reverse engineering on behalf of the LLVM team. The long-term idea is to improve CodeView support to the point where LLVM-compiled languages other than C/C++ (for instance, by way of the Clang compiler) can make robust use of CodeView and its tools.

LLVM supports WebAssembly as a linking target

WebAssembly, the binary format for applications delivered in a web browser, is starting to evolve from an experiment into a production technology. Key parts of the WebAssembly toolchain, such as Emscripten and PNaCL, use LLVM.

The latest step is support in LLVM’s linker tools for WebAssembly, by way of
the wasm-ld
command-line tool

. This tool ingests assembly created by LLVM when using the wasm32-unknown-unknown-wasm
target, and emits web-ready WebAssembly binaries.

Support for WebAssembly is still necessarily incomplete, as WebAssembly itself is a work in progress, but LLVM is likely to remain a key element in the WebAssembly stack.

LLVM improvements to Intel CPU support

LLVM programs can now take advantage of instruction scheduling on many families of Intel processor: Sandy Bridge, Ivy Bridge, Haswell, Broadwell, and Skylake. The Intel Icelake CPU is now a supported target, too.

LLVM now supports emitting intrinsics that work with Intel processor extensions used for vector processing: VAES, GFNI, VPCLMULQDQ, AVX512VBMI2, AVX512BITALG, and AVX512VNNI.

Code generation has been improved overall for various operations on Intel processors, such as memory comparisons, vector truncations, and vector multiplication with 32-bit integer values.




Compilers as a memory error detectors This is a small anecdote of something that happened me the other day. Internal compiler error I was building LLVM trunk with GCC 6.2.0 and th...
扩展LLVM的Checked C使C语言的空间内存更安全... Checked C是由Microsoft Research组织开发的 开源、合作项目 ,它的目标是扩展C语言,方便程序员写出更为可靠的程序,不会出现类似缓存溢出、越界内存访问以及不正确的类型转换等问题。Checked C的代码可以和标准C代码共存,方便移植。 即将在IEEE...
Phoronix SciMark benchmarking results Phoronix recently published an article “ Ryzen Compiler Performance: Clang 4/5 vs. GCC 6/7/8 Benchmarks ”, and there are many results in that arti...
PoC: compiling to eBPF from Rust I have been playing with eBPF (extended Berkeley Packet Filters) , a neat feature present in recent Linux versions (it evolved from the much older...
swift之typelayout 结构体和元组当前共享相同的布局算法,在编译器实现中称为“通用”布局算法。算法如下: 一开始设置size为0,alignment为1 遍历字段,对于每个字段: 先根据这个字段的alignment来更新size,让这个字段能够对齐 size增加这个...