From: Hans Wennborg Date: Thu, 29 Aug 2019 12:19:19 +0000 (+0000) Subject: ReleaseNotes: omitting range checks for switches with unreachable defaults X-Git-Tag: android-x86-9.0-r1~69 X-Git-Url: http://git.osdn.net/view?p=android-x86%2Fexternal-llvm.git;a=commitdiff_plain;h=e289ded26ca2b28004fbeb209240e90187afe9ef ReleaseNotes: omitting range checks for switches with unreachable defaults git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_90@370342 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/docs/ReleaseNotes.rst b/docs/ReleaseNotes.rst index b0e91443737..7130242cc49 100644 --- a/docs/ReleaseNotes.rst +++ b/docs/ReleaseNotes.rst @@ -85,6 +85,36 @@ Noteworthy optimizations `bug 42763 _` and `post commit discussion _`. +* LLVM will now omit range checks for jump tables when lowering switches with + unreachable default destination. For example, the switch dispatch in the C++ + code below + + .. code-block:: c + + int g(int); + enum e { A, B, C, D, E }; + int f(e x, int y, int z) { + switch(x) { + case A: return g(y); + case B: return g(z); + case C: return g(y+z); + case D: return g(x-z); + case E: return g(x+z); + } + } + + will result in the following x86_64 machine code when compiled with Clang. + This is because falling off the end of a non-void function is undefined + behaviour in C++, and the end of the function therefore being treated as + unreachable: + + .. code-block:: asm + + _Z1f1eii: + mov eax, edi + jmp qword ptr [8*rax + .LJTI0_0] + + Changes to the LLVM IR ----------------------