Commit 9adebd4b authored by Hans Wennborg's avatar Hans Wennborg
Browse files

ReleaseNotes: omitting range checks for switches with unreachable defaults

llvm-svn: 370342
parent f8ed27f5
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -85,6 +85,36 @@ Noteworthy optimizations
  `bug 42763 <https://bugs.llvm.org/show_bug.cgi?id=42763>_` and
  `post commit discussion <http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20190422/646945.html>_`.  

* 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
----------------------